1

I want to display the progress of wget using dialog box(gauge).

I found one solution on this site but it is not showing upto 100 percent. After 90 percent, the dialog freezes/stops and the code exits.

Is there any way to show dialog gauge for wget?

Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
samvijay
  • 197
  • 5
  • 14
  • http://stackoverflow.com/questions/4686464/howto-show-wget-progress-bar-only may be of interest if you haven't seen it already. – Insectatorious May 28 '12 at 17:06

1 Answers1

7
URL="http://upload.wikimedia.org/wikipedia/commons/4/4e/Pleiades_large.jpg"
wget "$URL" 2>&1 | \
 stdbuf -o0 awk '/[.] +[0-9][0-9]?[0-9]?%/ { print substr($0,63,3) }' | \
 dialog --gauge "Download Test" 10 100
Derek Schrock
  • 346
  • 1
  • 7
  • I wonder about the cases where this might not produce a number. But from my tests character 63-65 is the current percent. – Derek Schrock May 29 '12 at 02:10
  • Thanks Derek. I tried out your solution with some larger files. But the progress is not shown as soon as the download starts. It shows 0% for a while, and then, suddenly move to 50%, and then, to 100%. Did you face the same issue? Is there anything to be added/modified to this solution? – samvijay May 29 '12 at 16:10
  • I think it depends on the size of the file being downloaded. – Derek Schrock May 29 '12 at 19:48
  • Also, what do you mean a while? The above might not work very well for small files on a slow connection. Look at --progress in wget's man page to understand why. Each dot is 1k for default. – Derek Schrock May 29 '12 at 20:13
  • 2
    The delay you are seeing is the sequence of numbers being buffered in the pipe. Disable buffering as follows: wget "$URL" 2>&1 | stdbuf -o0 awk …etc – Vince Berk Nov 15 '13 at 21:25