06-10-2008
PING to one host in one background process
Hi All,
I'm doing one script on Juniper router where you have one FreeBSD Shell:
Is pinging from time to time one ethernet port of othere router and in case of fail is blocking one port entering in CLI and doing some command:
If I run this script all is working perfectly, but if I run in Backgroung using "&" is blocked on ping (ping -c1 $RemoteIPAddress) . Could you help me to solve this problem?
Many thanks
giancarlo
#!/bin/sh
# Name of Script that will be show in log file ##############################################################
ScriptName='CheckLinkScript_Ze2-NS2'
# Remote Interface IP Address ##############################################################
RemoteIPAddress="10.15.100.222"
# Local Port connected to Remote IP Address ##############################################################
LocalPort="fe-2/0/1.23"
# Variable used for show time on log file ##############################################################
RIGHT_NOW=$(date +"%x %r %Z")
# Time between ping to Remote IP Address ##############################################################
SleepingTime='3'
# When interface is down after RentryTime will be sut up and Attemp of ping will be performed ##############
RetryTime='1000'
subping ()
{
echo ---$RIGHT_NOW---$ScriptName---- PERFORMING LINK CHECK RemoteIP $RemoteIPAddress LocalPort $LocalPort -- >> /var/log/messages
ping -c1 $RemoteIPAddress
if [ $? -ne 0 ]
# when is down #################################################################################################### ##
then
echo ---$RIGHT_NOW---$ScriptName---- Remote IP address $RemoteIPAddress unreachable -- > /var/log/messages
echo ---$RIGHT_NOW---$ScriptName---- Shutting down port &LocalPort -- > /var/log/messages
cli <<END_SCRIPT
edit
set interfaces $LocalPort disable
# shut interface ####################################################################################################
commit
top
exit
exit
echo ---$RIGHT_NOW---$ScriptName---- Port &LocalPort Admin DOWN -- > /var/log/messages
END_SCRIPT
sleep $RetryTime
# after sleep try to put up interface and try again to ping ##########################################################
echo ---$RIGHT_NOW---$ScriptName---- Attempt to recover link on port &LocalPort -- > /var/log/messages
cli <<END_SCRIPT
edit
dele interfaces $LocalPort disable
commit
top
exit
exit
END_SCRIPT
# when is up #################################################################################################### #####
else
echo ---$RIGHT_NOW---$ScriptName---- LINK CHECK Performed RemoteIP $RemoteIPAddress : OK -- > /var/log/messages
fi
}
while [ true ]
do
subping
sleep $SleepingTime
done
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi, dear all, I am rather new to Unix and have this problem where I cant seem to ping from 1 host to another. The scenerio is as follows: -
1 QNX host->Eth->1 SCO host
the SCO host is configured with it's IP
the QNX host is configured with another IP
both in the same domain, ie, 172.20.3.XX... (3 Replies)
Discussion started by: gavon
3 Replies
2. IP Networking
The problem I am facing now is that the QNX host could not ping the SCO host and vice versa. They are in the same domain, ie, 172.20.3.xx. As I am very new to Unix, I guess I must have missed out some important steps. Pls help... Thanx alot (2 Replies)
Discussion started by: gavon
2 Replies
3. Shell Programming and Scripting
hello to everyone, i was wondering if you could help me with a script im working on, it's kind of simple but i dont have a lot experience on unix comands: well, here it is:
you might apreciate the infinite while loop :D, it is supossed to be running on the server all day scaning it every 5... (12 Replies)
Discussion started by: sx3v1l_1n51de
12 Replies
4. Solaris
Hello,
I have a problem - I created a chrooted jail for one user. When I'm logged in as root, everything work fine, but when I'm logged in as a chrooted user - I have many problems:
1. When I execute the command ping, I get weird results:
bash-3.00$ usr/sbin/ping localhost ... (4 Replies)
Discussion started by: Przemek
4 Replies
5. Shell Programming and Scripting
Hi All,
I'm doing one script on Juniper router where you have one FreeBSD Shell:
Is pinging from time to time one ethernet port of othere router and in case of fail is blocking one port entering in CLI and doing some command:
If I run this script all is working perfectly, but if I run in... (0 Replies)
Discussion started by: teigipo
0 Replies
6. IP Networking
Hi,
I have a weird problem.
when ever I do ping command like for example
ping unix.comI get the following message:
# ping unix.com
ping: unknown host unix.com
but when I use host the computer is able to know the host.
# host unix.com
unix.com has address 81.17.242.186
unix.com mail is... (2 Replies)
Discussion started by: programAngel
2 Replies
7. Solaris
i am using solaris 10 and i am able to ping all the hosts but i am not able to traceroute any of them. how to fix this? (9 Replies)
Discussion started by: chidori
9 Replies
8. Shell Programming and Scripting
Hi I am trying to write a script which runs until the host is up. i got it figured out that it needs to be in loop till it return $? = 0.
Not getting it through though. I am not sure about the 6th line !!!
#!/bin/sh
HOSTS="host.txt"
ping(){
for myhost in "$HOSTS"
do
ping -c -1 "$myhost"... (8 Replies)
Discussion started by: Antergen
8 Replies
9. Shell Programming and Scripting
Hi All,
I have the requirement where am pinging the server and matching the IP address with the existing IP address. Below code is returning me the IP address and my requirement is i have to see that also whether it is pinging or not
PING useipapd01 (172.22.32.87) 56(84) bytes of data.
64... (1 Reply)
Discussion started by: sharsour
1 Replies
10. AIX
Actually. I was getting a ping to remote host failed for one of my etherchannel. When I checked it was in backup adapter and again I use to faileover and brought to primary channel.
But it was again going to backup channel and giving me the alert ping to remotehost failed. When I checked the load... (3 Replies)
Discussion started by: Mohamed Thamim
3 Replies
BPING(1) BP executables BPING(1)
NAME
bping - Send and receive Bundle Protocol echo bundles.
SYNOPSIS
bping [-c count] [-i interval] [-p priority] [-q wait] [-r flags] [-t ttl] srcEID destEID [reporttoEID]
DESCRIPTION
bping sends bundles from srcEID to destEID. If the destEID echoes the bundles back (for instance, it is a bpecho endpoint), bping will
print the round-trip time. When complete, bping will print statistics before exiting. It is very similar to ping, except it works with
the bundle protocol.
bping terminates when one of the following happens: it receives the SIGINT signal (Ctrl+C), it receives responses to all of the bundles it
sent, or it has sent all count of its bundles and waited wait seconds.
EXIT STATUS
These exit statuses are taken from ping.
0 bping has terminated normally, and received responses to all the packets it sent.
1 bping has terminated normally, but it did not receive responses to all the packets it sent.
2 bping has terminated due to an error. Details should be noted in the ion.log log file.
FILES
No configuration files are needed.
ENVIRONMENT
No environment variables apply.
DIAGNOSTICS
Diagnostic messages produced by bping are written to the ION log file ion.log and printed to standard error. Diagnostic messages that
don't cause bping to terminate indicate a failure parsing an echo response bundle. This means that destEID isn't an echo endpoint: it's
responding with some other bundle message of an unexpected format.
Can't attach to BP.
bpadmin has not yet initialized Bundle Protocol operations.
Can't open own endpoint.
Another application has already opened ownEndpointId. Terminate that application and rerun.
bping bundle reception failed.
BP system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
No space for ZCO extent.
ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
Can't create ZCO.
ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
bping can't send echo bundle.
BP system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
BUGS
Report bugs to <ion-bugs@korgano.eecs.ohiou.edu>
SEE ALSO
bpecho(1), bptrace(1), bpadmin(1), bp(3), ping(8)
perl v5.14.2 2012-05-25 BPING(1)