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
SCROLLKEEPER-REBUILDDB(8)				      System Manager's Manual					 SCROLLKEEPER-REBUILDDB(8)

NAME
scrollkeeper-rebuilddb - rebuild the scrollkeeper document catalog database SYNOPSIS
scrollkeeper-rebuilddb [-p path ] [-v] [-q] DESCRIPTION
This rebuilds the ScrollKeeper database from the original OMF metadata files and documents. Under normal situations, this tool is not nec- essary. It is useful however if the database becomes corrupt, which could be caused by interruption of ScrollKeeper during an update of the database. Errors and warnings are logged to /var/log/scrollkeeper.log. OPTIONS
-p path Use path as the ScrollKeeper database directory. -v Verbose. Show warnings and error messages in addition to logging them to /var/log/scrollkeeper.log. -q Run in quiet mode, suppressing output of all but the most serious warning and error messages to STDOUT. Note that most output to the log file will be unchanged. FILES
/var/lib/scrollkeeper/scrollkeeper_docs /var/lib/scrollkeeper/TOC/<docnumber> /var/lib/scrollkeeper/<locale>/scrollkeeper_cl.xml /var/lib/scrollkeeper/<locale>/scrollkeeper_extended_cl.xml /var/log/scrollkeeper.log AUTHOR
Laszlo Kovacs <laszlo.kovacs@sun.com> Dan Mueth <d-mueth@uchicago.edu> SEE ALSO
scrollkeeper-config(1), scrollkeeper-gen-seriesid(1), scrollkeeper.conf(5), scrollkeeper(7), scrollkeeper-preinstall(8), scrollkeeper- update(8) scrollkeeper Dec 5, 2001 SCROLLKEEPER-REBUILDDB(8)
All times are GMT -4. The time now is 01:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy