LoginSignup
0
0

More than 1 year has passed since last update.

Use cases of wget

Posted at

download files from list

assumes list.txt contains following

voice-record.mp3
agenda.docx
minutes.docx

after executes this command

wget -i list.txt --base="http://your.site/page/"

following files will be downloaded

http://your.site/page/voice-record.mp3
http://your.site/page/agenda.docx
http://your.site/page/minutes.docx

add headers of http request

wget --referer="https://www.bbc.co.uk/" --header="User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0" "https://www.bbc.co.uk/weather"

check web server is ready to serve after restart

wget -O/dev/null --timeout=5 --waitretry=15 --tries=27 --retry-connrefused --quiet "http://your.site/page"

Options

  • -O/dev/null: saves downloaded content to /dev/null, i.e. doesn't keep
  • timeout=5: 5 seconds connection timeout
  • waitretry=15: waits up to 15 seconds in next try. By default, extra 1 second waiting time is added on next try, start from 1 second
  • tries=27: tries to connect 27 times
  • retry-connrefused: retries even though destination refuses to connect. Without apply this flag program terminates when destination refuses to connect
  • quiet: doesn't output anything to console

wget returns 0 when success, otherwise returns 4.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0