Use cases of wget
Salad Lam
Posted on January 31, 2024
Notice
I wrote this article and was originally published on Qiita on 18 March 2023.
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.
๐ ๐ช ๐
๐ฉ
Salad Lam
Posted on January 31, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
undefined Anytime i install linux on a new machine or start fresh, this is where i will regain all of my cli tools.
November 28, 2024
linux Steps to Use .NET on the Forlinx OKMX6UL Series Development Board (Linux4.1.15)
November 29, 2024
cloud Cloud Monitoring and Logging: Key Tools and Practices for Ensuring Cloud Reliability
November 29, 2024
operatingsystem Understanding the Core Components of an Operating System and How They Work
November 29, 2024