$ if perl sshping.pl localhost; then echo up; else echo down; fi Connecting to port 22... connect() failed: Connection refused at sshping.pl line 14. down