Hands-on task
Check Service Availability
Write /usr/local/bin/portcheck host port: if the TCP port is open — exit 0, if closed — exit 1. It's tested against a live service (port 6500) and a closed one (port 6599).
The script is easiest to write in the Editor tab: /usr/local/bin shows up there in the file tree; run and test it in the terminal.
- exit code
- /dev/tcp
- port check
- bash script
- timeout