Sponsored Content
Top Forums UNIX for Dummies Questions & Answers PING to one host in one background process Post 302203982 by teigipo on Tuesday 10th of June 2008 10:04:03 AM
Old 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

Unable to ping host

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

QNX host cannot ping SCO host, vice versa

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

help to ping a host, is it alive or not ...

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

PING - Unknown host 127.0.0.1, Unknown host localhost - Solaris 10

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

Script for ping on 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... (0 Replies)
Discussion started by: teigipo
0 Replies

6. IP Networking

ping can not recognize host but host command can

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

able to ping all hosts but not able to traceroute any host

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

Ping Host Until it is up and email

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

Ping Response from the host name

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

Ping to remote host failed

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
dceping(8)																dceping(8)

NAME
dceping - test the ability to contact DCE services from a local DCE client. SYNOPSIS
dceping [-n number] [-s time] [-v] [-C] [service_name ...] required to specify the literal strings, NAMESPACE or STRING_BINDING (see nond- cesvc(4)). OPTIONS
-n number Specify the number of pinging cycles. Each service is tested once per cycle. The default is one pinging cycle. Specifying -n 0 makes pinging continuous. -s time Specify time, in seconds, to wait between pinging cycles. You must specify more than one pinging cycle with the -n option in order to use -s. -v Run in verbose mode. -C Ping only core DCE services. This option is ineffective if a service_name is specified on the command line. DESCRIPTION
dceping verifies that a local DCE client can communicate with DCE and other services. It uses the RPC management interface to determine if the DCE service is listening. The core DCE services that dceping checks include secd, cdsd, gdad, rpcd, cdsadv, dtsd, and sec_clientd. You can ping other DCE and non-DCE services by naming them in the file, /opt/dcelocal/hpadmin/etc/nondcesvc. If you want to determine at run time what services you want dceping to ping, you may do so using the same file. See the manpage, nondcesvc(4), for more information. You may specify the services to ping on the command line separated by blanks. In this case, dceping does not ping any DCE core services or the services listed in /opt/dcelocal/hpadmin/etc/nondcesvc. The service_name specified could be either a name in the DCE Cell Directory Service Namespace or an RPC string binding. It is not AUTHOR
dceping was developed by HP. FILES
/opt/dcelocal/hpadmin/etc/nondcesvc /opt/dcelocal/hpadmin/etc/wellknownif SEE ALSO
nondcesvc(4), wellknownif(4) HP DCE
dceping(8)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy