Hands-on task
A URL probe with the code in a log
Write a script /usr/local/bin/probe that takes a URL as its first argument. If the server answered with code 200, the script writes nothing; otherwise it appends the line FAIL <code> <url> to /var/log/probe.log, e.g. FAIL 404 http://127.0.0.1:18090/missing. When there's no connection at all, the code is whatever curl returned (000). A local site to try the script on is already running at http://127.0.0.1:18090/.
It's handy to write the script in the Editor tab: create the file /usr/local/bin/probe there, and run and test it in the terminal.
- curl -w
- http codes
- bash scripts
- script arguments
- appending to a log