eMarcel.com

Oracle Database, Fusion Middleware, Linux

Validate connection to remote host – Sprawdzanie łączności z hostem

  • A simple connection test 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#

 


 

 

 

 

  • and the other way, below script will check the connection and after 30 seconds will write the result to root session screen if connection cennot be established, nice small network monitor which can be executed by crontab, for instance.

 

 

#!/bin/bash   /bin/ping -c1 -W30 192.168.0.1 >/dev/null 2>&1   if [ $? != 0 ]; then write root < /root/noconnect #in this file we write the messages to be displayed fi   #END-SCRIPT#

 

 

 

 

 

(Visited 14 times, 1 visits today)

0 Shares
Tweet
Share
+1
Share

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.

Close