document updated 1 year, 9 months ago, on Feb 17, 2023
ways to minimally check if a remote service is working
- check that a TCP port is minimally responsive
perl -MIO::Socket::INET -le 'IO::Socket::INET->new(PeerAddr=>shift,Timeout=>4)||die $!;print"Connected successfully"' paperlined.org:22
- using Bash —
timeout 4 bash -c ">/dev/tcp/paperlined.org/22" && echo Port open || echo Port closed
- using curl —
timeout 4 curl --connect-timeout 3.7 telnet://paperlined.org:22
python3 -c "import socket;print(True) if 0 == socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(('paperlined.org',22)) else False"
- using netcat —
timeout 4 nc -v paperlined.org 22 </dev/null 2>&1 | (head -n1 && tail -n1)
- (note: there are many versions of netcat, and each act subtly differently)
- check that a web host is minimally responsive:
curl --head https://paperlined.org/
wget -q --no-check-certificate -O /dev/null -S https://paperlined.org/
- a list of SQL queries that should always succeed, even when a user has no permissions