How to Show the Wget Progress Bar Only

How can I show the wget progress bar only?

You can use the following filter:

progressfilt ()
{
local flag=false c count cr=$'\r' nl=$'\n'
while IFS='' read -d '' -rn 1 c
do
if $flag
then
printf '%s' "$c"
else
if [[ $c != $cr && $c != $nl ]]
then
count=0
else
((count++))
if ((count > 1))
then
flag=true
fi
fi
fi
done
}

Usage:

$ wget --progress=bar:force http://somesite.com/TheFile.jpeg 2>&1 | progressfilt
100%[======================================>] 15,790 48.8K/s in 0.3s

2011-01-13 22:09:59 (48.8 KB/s) - 'TheFile.jpeg' saved [15790/15790]

This function depends on a sequence of 0x0d0x0a0x0d0x0a0x0d being sent right before the progress bar is started. This behavior may be implementation dependent.

how to start wget in cmd with start command and show only progress bar?

The download progress window could be opened with the wanted properties with following command line:

start "Download Progress" /wait %ComSpec% /D /T:fg /C "%SystemRoot%\System32\mode.com CON COLS=80 LINES=1 & wget.exe -q -c --show-progress https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-workbench-community-8.0.23-winx64.msi"

The Windows command processor cmd.exe processing the batch file starts with command start one more command processor referenced with predefined environment variable ComSpec with the options:

  • /D to disable execution of AutoRun commands from registry,
  • /T:fg to define the foreground and background color (both 0-9A-F) of the console window,
  • /C to execute the command line specified next and then close itself.

The options are explained by the usage help output on running cmd /? in an opened command prompt window.

The title for the console window is Download Progress as defined already by start which waits for self-termination of started cmd.exe instance. Run start /? in command prompt window for help on this command.

The command line executed by the started command process first runs command MODE to change the number of columns to 80 and the number of lines to 1, i.e. the additional console window becomes very small. Run mode /? in command prompt window for help on this command.

The small additional console window displays only the progress information of wget.exe which is executed next by the second command processor instance.

See also single line with multiple commands for an explanation of the operator &.

Python wget module doesn't show progress bar

This works for me,

#create this bar_progress method which is invoked automatically from wget
def bar_progress(current, total, width=80):
progress_message = "Downloading: %d%% [%d / %d] bytes" % (current / total * 100, current, total)
# Don't use print() as it will print in new line every time.
sys.stdout.write("\r" + progress_message)
sys.stdout.flush()

#Now use this like below,
url = 'http://url_to_download'
save_path = "/home/save.file"
wget.download(url, save_path, bar=bar_progress)

Is it possible to adapt wget's progress bar to several files?

No, currently there is no way in Wget to have a single aggregate bar.

However, you can try the alpha version of Wget 2.0. It's not exactly what you're looking for, but comes very close. It has been packages as Wget2 in Debian and is available on Arch Linux's AUR. I'm not sure about other distros.

wget2 supports parallel downloads and HTTP/2 by default and a line under the progress bars showing some aggregate stats. For example:

$ wget2 --progress=bar "example.com/?"{0,1,2,3,4,5,6,7,8}
index.html?8 100% [========================================================================================================================>] 606 32,88KB/s
index.html?5 100% [========================================================================================================================>] 606 18,49KB/s
index.html?6 100% [========================================================================================================================>] 606 31,15KB/s
index.html?7 100% [========================================================================================================================>] 606 32,88KB/s
index.html?4 100% [========================================================================================================================>] 606 34,81KB/s
[Files: 9 Bytes: 5,33K [11,78KB/s] Redirects: 0 Todo: 0 Errors: 0 ]

You see 5 progress bars because 5 threads were used to download the 9 files in parallel. The last bar indicates aggregate stats.

You can easily build Wget2 from git or using the v1.99 tarball available here: https://alpha.gnu.org/gnu/wget/wget2-1.99.0.tar.gz

DISCLAIMER: I maintain both GNU Wget and Wget2.

delay wget progress bar display interval

wget knows the --progress option, that allows you to tweak the output settings a bit. An excerpt from the manpage:

   --progress=type
Select the type of the progress indicator you wish to use. Legal indicators are
"dot" and "bar".

[...]The "bar" indicator is used by default. It draws an ASCII progress bar graphics
(a.k.a "thermometer" display) indicating the status of retrieval. If the output is
not a TTY, the "dot" bar will be used by default.

Use --progress=dot to switch to the "dot" display. It traces the retrieval by
printing dots on the screen, each dot representing a fixed amount of downloaded data.

The progress type can also take one or more parameters. The parameters vary based on
the type selected. Parameters to type are passed by appending them to the type
sperated by a colon (:) like this: --progress=type:parameter1:parameter2.

When using the dotted retrieval, you may set the style by specifying the type as
dot:style. Different styles assign different meaning to one dot. With the "default"
style each dot represents 1K, there are ten dots in a cluster and 50 dots in a line.
The "binary" style has a more "computer"-like orientation---8K dots, 16-dots clusters
and 48 dots per line (which makes for 384K lines). The "mega" style is suitable for
downloading large files---each dot represents 64K retrieved, there are eight dots in
a cluster, and 48 dots on each line (so each line contains 3M). If "mega" is not
enough then you can use the "giga" style---each dot represents 1M retrieved, there
are eight dots in a cluster, and 32 dots on each line (so each line contains 32M).

With --progress=bar, there are currently two possible parameters, force and noscroll.

When the output is not a TTY, the progress bar always falls back to "dot", even if
--progress=bar was passed to Wget during invokation. This behaviour can be overridden
and the "bar" output forced by using the "force" parameter as --progress=bar:force.

By default, the bar style progress bar scroll the name of the file from left to right
for the file being downloaded if the filename exceeds the maximum length allotted for
its display. In certain cases, such as with --progress=bar:force, one may not want
the scrolling filename in the progress bar. By passing the "noscroll" parameter,
Wget can be forced to display as much of the filename as possible without scrolling
through it.

Note that you can set the default style using the "progress" command in .wgetrc.
That setting may be overridden from the command line. For example, to force the bar
output without scrolling, use --progress=bar:force:noscroll

I recommend to read the whole thing to understand how wgets progress meter works, but these are the important points in a nutshell:

  • if the output is not a tty, wget will use the dot display method
  • the dot display method displays a . per X number of bytes downloaded
  • X can be tweaked by passing --progress=dot:<style> to the wget call
  • style can be one of:

    • default: 1KB per dot
    • binary: 8KB per dot
    • mega: 64KB per dot
    • giga: 1MB per dot

To summarize, in order to reduce the output when downloading a large file, you would invoke wget as follows:

$> wget --progress=dot:mega <url>


Related Topics



Leave a reply



Submit