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
LEARN ABOUT SUNOS
asadmin-jms-ping
asadmin-jms-ping(1AS) User Commands asadmin-jms-ping(1AS)
NAME
jms-ping - checks to see if the JMS provider is up and running
SYNOPSIS
jms-ping --user admin_user [--password admin_password] [--host localhost] [--port 4848] [--passwordfile filename] [--secure|-s]
[--terse=false] [--echo=false] [--interactive=false]
Checks to see if the JMS provider is up and running. This command is supported in remote mode only.
OPTIONS
--user authorized domain application server administrative username.
--password password to administer the domain application server.
--host machine name where the domain application server is running.
--port port number of the domain application server listening for administration requests.
--passwordfile file containing the domain application server password.
--secure if true, uses SSL/TLS to communicate with the domain application server.
--terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well-
formatted data for consumption by a script. Default is false.
--echo setting to true will echo the command line statement on the standard output. Default is false.
--interactive if set to true (default), only the required password options are prompted.
Example 1: Using jms-ping
asadmin> jms-ping --user admin --password adminadmin --host bluestar --port 4848 server1
JMS Ping Status=RUNNING
EXIT STATUS
0 command executed successfully
1 error in executing the command
asadmin-create-jmsdest(1AS), asadmin-delete-jmsdest(1AS), asadmin-list-jmsdest(1AS)
J2EE 1.4 SDK March 2004 asadmin-jms-ping(1AS)