[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: How to monitor wget command progress in ruby?

Dan Diebolt

2/9/2009 12:32:00 AM

[Note: parts of this message were removed to make it a legal post.]

Look at the chart on that page. If you want to read character by character wget's stdout

pipe = IO.popen("command", "r")

Sorry I don't have time to write an example but this should point your in the right direction
15 Answers

Joao Silva

2/9/2009 12:51:00 AM

0

Great! I was write code:

f = IO.popen("wget http://www.hostgator.com/te... 2>&1", "r") {
|pipe|
pipe.each do |line|
sleep 1.5
puts line
end
}

and it's almost done - it's outputs something like this:

8350K .......... .......... .......... .......... .......... 41% 230K
54s
8400K .......... .......... .......... .......... .......... 41% 226K
54s
8450K .......... .......... .......... .......... .......... 41% 229K
53s
8500K .......... .......... .......... .......... .......... 41% 221K
53s
8550K .......... .......... .......... .......... .......... 41% 234K
53s
8600K .......... .......... .......... .......... .......... 42% 226K
53s
8650K .......... .......... .......... .......... .......... 42% 233K
53s
8700K .......... .......... .......... .......... .......... 42% 222K
52s
8750K .......... .......... .......... .......... .......... 42% 233K
52s
8800K .......... .......... .......... .......... .......... 43% 224K
52s
8850K .......... .......... .......... .......... .......... 43% 222K
52s
8900K .......... .......... .......... .......... .......... 43% 237K
51s
8950K .......... .......... .......... .......... .......... 43% 229K
51s
9000K .......... .......... .......... .......... .......... 44% 230K
51s
9050K .......... .......... .......... .......... .......... 44% 229K
51s
9100K .......... .......... .......... .......... .......... 44% 222K
51s

great....but i need explaination: what does "2>&1", "r"" mean? without
it code:

f = IO.popen("wget http://www.hostgator.com/te...", "r") { |pipe|
pipe.each do |line|
sleep 1.5
puts line
end
}

Didn't work. I would like avoid copypaste coding, i found 2>&1 in some
tutorial.
--
Posted via http://www.ruby-....

Karl-Heinz Wild

2/9/2009 1:48:00 AM

0



Choi, Junegunn

2/9/2009 3:08:00 AM

0

> great....but i need explaination: what does "2>&1", "r"" mean? without
> it code:

* '2>&1' says that standard error stream (whose file desecriptor is 2)
will be redirected
to the same place where the standard output stream is sent. Since wget
sends its output
to standard error, you need this redirection to capture the output using pipe.

Take the following commands with pipes as an example.

> ls / | wc
30 30 181
> ls ___no_such_path___ | wc
ls: cannot access ___no_such_path___: No such file or directory
0 0 0
> ls ___no_such_path___ 2>&1 | wc
1 9 64

Incidentally, '2>&1' is often used to suppress error messages and
standard output.

> some_command > /dev/null 2>&1
>


* 'r' means you are opening the pipe in read-only mode.

volkfolk

3/15/2011 11:04:00 PM

0

On Mar 15, 6:34 pm, Neil X <nei...@yahoo.com> wrote:
> On Mar 15, 6:15 pm, the felonious kidd <bob_a...@hotmail.com> wrote:
>
> > On Mar 14, 3:55 pm, "sweetbac" <sweet...@sbcglobal.net> wrote:
>
> > > Some real jagoffs posting to the SF Chronicle
>
> > Some real jagoffs posting to the <insert news website or blog name
> > here>
>
> > I take a glance at reader comments once in a while, when I get to
> > feeling too optimistic about the future of mankind. It brings me right
> > back the reality that there are far too few Darwin awards being handed
> > out.
>
> The more liberal the newspaper, the more voracious that right wing
> commenters are.  It's weird.  If you read the comments section at the
> Boston Globe, the frothing right wing rhetoric is way, way more over
> the top than you see if you read the comments section at Rupert
> Murdoch's Boston Herald.
>
> Peace,
> Neil X.

Murdoch hasn't owned the Herald since 1994. He was forced to sell it
when he bought Channel 25

Scot

DGDevin

3/15/2011 11:53:00 PM

0



"the felonious kidd" wrote in message
news:50b90473-98e5-4d87-95e9-fcddc673dada@i35g2000prd.googlegroups.com...

> I take a glance at reader comments once in a while, when I get to
> feeling too optimistic about the future of mankind. It brings me right
> back the reality that there are far too few Darwin awards being handed
> out.

I generally ignore reader comment sections as it seems the majority of
people who post there suffer serious mental illness or at least want to
create that impression. If there were a practical way to require such
submissions be signed with the poster's real name, I bet 90% of those
comments would never be made.

Dave Kelly

3/16/2011 3:39:00 PM

0


"volkfolk" <volkfolk1@verizon.net> wrote in message

> He was forced to sell it when he bought Channel 25

> Scot

The Spice channel?
Nice.


volkfolk

3/16/2011 9:36:00 PM

0

On Mar 16, 11:39 am, "sweetbac" <sweet...@sbcglobal.net> wrote:
> "volkfolk" <volkfo...@verizon.net> wrote in message
> > He was forced to sell it when he bought Channel 25
> > Scot
>
> The Spice channel?
> Nice.

That would be Fox 25, home of the Simpsons, Family Guy and American
Idol

Scot

Neil X

3/17/2011 4:03:00 AM

0

On Mar 15, 7:03 pm, volkfolk <volkfo...@verizon.net> wrote:
> On Mar 15, 6:34 pm, Neil X <nei...@yahoo.com> wrote:
>
>
>
>
>
>
>
>
>
> > On Mar 15, 6:15 pm, the felonious kidd <bob_a...@hotmail.com> wrote:
>
> > > On Mar 14, 3:55 pm, "sweetbac" <sweet...@sbcglobal.net> wrote:
>
> > > > Some real jagoffs posting to the SF Chronicle
>
> > > Some real jagoffs posting to the <insert news website or blog name
> > > here>
>
> > > I take a glance at reader comments once in a while, when I get to
> > > feeling too optimistic about the future of mankind. It brings me right
> > > back the reality that there are far too few Darwin awards being handed
> > > out.
>
> > The more liberal the newspaper, the more voracious that right wing
> > commenters are.  It's weird.  If you read the comments section at the
> > Boston Globe, the frothing right wing rhetoric is way, way more over
> > the top than you see if you read the comments section at Rupert
> > Murdoch's Boston Herald.
>
> > Peace,
> > Neil X.
>
> Murdoch hasn't owned the Herald since 1994. He was forced to sell it
> when he bought Channel 25


It is indeed 17 years since the Herald was officially part of
Newscorp, but their ideological bent has never varied an iota. My
point stands, despite the factual inaccuracy you highlight.

Peace,
Neil X.

volkfolk

3/17/2011 1:41:00 PM

0

On Mar 17, 12:03 am, Neil X <nei...@yahoo.com> wrote:
> On Mar 15, 7:03 pm, volkfolk <volkfo...@verizon.net> wrote:
>
>
>
> > On Mar 15, 6:34 pm, Neil X <nei...@yahoo.com> wrote:
>
> > > On Mar 15, 6:15 pm, the felonious kidd <bob_a...@hotmail.com> wrote:
>
> > > > On Mar 14, 3:55 pm, "sweetbac" <sweet...@sbcglobal.net> wrote:
>
> > > > > Some real jagoffs posting to the SF Chronicle
>
> > > > Some real jagoffs posting to the <insert news website or blog name
> > > > here>
>
> > > > I take a glance at reader comments once in a while, when I get to
> > > > feeling too optimistic about the future of mankind. It brings me right
> > > > back the reality that there are far too few Darwin awards being handed
> > > > out.
>
> > > The more liberal the newspaper, the more voracious that right wing
> > > commenters are.  It's weird.  If you read the comments section at the
> > > Boston Globe, the frothing right wing rhetoric is way, way more over
> > > the top than you see if you read the comments section at Rupert
> > > Murdoch's Boston Herald.
>
> > > Peace,
> > > Neil X.
>
> > Murdoch hasn't owned the Herald since 1994. He was forced to sell it
> > when he bought Channel 25
>
> It is indeed 17 years since the Herald was officially part of
> Newscorp, but their ideological bent has never varied an iota.  My
> point stands, despite the factual inaccuracy you highlight.
>
> Peace,
> Neil X.

No argument there. I was just pointing out that it's no longer owned
by Murdoch. I like Marjorie Egan though. She's the only columnist at
the Herald who has any clue at all. I like her on the radio and on
Emily Rooney's show on GBH as well

Scot

wyeknot

3/17/2011 8:51:00 PM

0

On Mar 17, 9:40 am, volkfolk <volkfo...@verizon.net> wrote:
> No argument there. I was just pointing out that it's no longer owned
> by Murdoch. I like Marjorie Egan though. She's the only columnist at
> the Herald who has any clue at all. I like her on the radio and on
> Emily Rooney's show on GBH as well

Though I only occasionally agree with her (Eagan), that is no
requirement for me to like listening to someone's take on current
events. But she's always has too much saliva in her mouth and the
sound, especially thru super-mics on the radio, kind of bugs me. She
needs the dentists' "Mr Thirsty" machine. I do rarely miss Emily
Rooney though, M-F, she calls them like she sees them - is she off GB
this week due to the WGBH contract impasse?

Matt