A simple script to test connection to a remote host
#!/bin/bash n_sec=2 #ping waits n of seconds REMOTE_HOST_IP=192.168.0.1 ping -c $n_sec $REMOTE_HOST_IP >/dev/null if [ $? -eq 0 ]; then echo "Ping OK" else "Host is not available" fi #END-SCRIPT#
Below script will check the connection, if connection cannot be established for 30 seconds it will write results to root session screen. Very nice and small network monitor tool, which can be executed by e.g. a crontab.
#!/bin/bash /bin/ping -c1 -W30 192.168.0.1 > /dev/null 2>&1 if [ $? != 0 ]; then write root < /root/noconnect #this file stores the message fi #END-SCRIPT#
By continuing to use the site, you agree to the use of cookies. more information
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.