Question

I'm trying to relay the stdout of wget using net::ssh. Even though I have it setup like this:

ssh.exec! cmd do |ch, stream, data|
  print data
end

I'm getting output like this:

  0K .......... .......... .......... .......... ..........  1% 18.8M 0s
 50K .......... .......... .......... .......... ..........  3% 23.7M 0s
100K .......... .......... .......... .......... ..........  4% 22.7M 0s
150K .......... .......... .......... .......... ..........  6% 23.8M 0s

When I expect everything to be printed on the same line with a thermometer progress bar. What am I doing wrong?

EDIT

This may actually have more to do with the remote process (in this case wget) than my setup. When running locally I get output that looks like this:

100%[============================>] 3,208,462   7.65M/s   in 0.4s

Which is quite different than what I'm getting via ssh.

Was it helpful?

Solution

In this case it looks like wget is the culprit and not the carriage returns I suspected.

There are two progress output modes bar and dot. Bar is default if the output is a tty (which is what I have locally) but dot is the default in non-tty sessions (which is what I have via ssh). The dot progress bar does not have carriage returns. So that explains why I'm not seeing them.

Adding the option --progress=bar:force to the wget call works as expected, carriage returns and all.

I'll keep this here and rename the question a bit in case anyone every stumbles into this issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top