Ports by hand
wget
The wget command fetches a page or file over HTTP or HTTPS and saves it, or prints it with -O -.
wget URL downloads the page into a file named after the URL, and -q -O - prints the page to the screen and
nothing else. Small Linux systems carry it where curl is missing, because BusyBox builds it in. Its one-line errors
name the failing step: bad address (the name didn't turn into an address), can't connect (no connection to the
server) and server returned error (the server answered, with a 4xx or 5xx status).
wget command usage
wget [-q] [-O FILE] [-T SECONDS] [-S] URL
Options
-
-q - quiet: no progress lines
-
-O - - write the page to the screen; a name after -O writes it to that file instead
-
-T 5 - how many seconds to wait before giving up
-
-S - print the response's headers
wget examples
-
wget http://webServer.lab/ - Downloads the front page into a file named index.html.
-
wget -q -O - http://webServer.lab/ - Prints the page to the screen and nothing else.
-
wget -O page.html http://webServer.lab/ - Saves the page in the file page.html.
-
wget -S -O /dev/null http://webServer.lab/ - Prints the response's headers and throws the page away.
-
wget -T 5 http://webServer.lab/ - Gives up after five seconds with no answer.
Reading the output
$ wget -q -O - http://zoe.lab:81/ wget: can't connect to remote host (10.0.2.10): Connection refused
can't connect: the name turned into an address, so DNS is fine, and no connection formed.Connection refused: the machine answered, and nothing listens on that port.
Pitfalls
- The full
wgethides its errors under-q: drop the flag when something fails. BusyBox's still prints them.