I have a bash script that uses rsync to backup files from two remote workstations (unix and linux) to a local hard drive. I want the script to check that the workstation is online before running rsync. The easiest way I could think of is to use ping:
ping -s 1 -c 1 $SERVN > /dev/null; echo $?
This works fine for one workstation, but for security reasons, pinging is disabled on the other one. I tried nc and it also does not work. I also tried to "ping" the machine using ssh or rsync, but of course I get a password prompt, which kind of defies the purpose of doing this in the first place. Anybody got any suggestion/idea? thanks
nc -z $SERVN > /dev/null; echo $?
should do the job. or even without redirection to /dev/null.