Sponsored Content
Top Forums Shell Programming and Scripting Script for ping on Background Process Post 302203986 by teigipo on Tuesday 10th of June 2008 10:08:54 AM
Old 06-10-2008
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 Backgroung using "&" is blocked on ping (ping -c1 $RemoteIPAddress) . Could you help me to solve this problem?

Many thanks
giancarlo


Code:
#!/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. Shell Programming and Scripting

capture the process id when starting a background process

Hello all, How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename. Any assistance is most appreciated. Thanks, Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies

2. Shell Programming and Scripting

How to include RETURN KEY with Background process "&" in Shell Script

Hello All, I am a newbie in Shell script programming, and maybe you can help me with my query. I need to write a shell script (mntServer.ksh) that will start a background process and also to be able to run another script. The mntServer.ksh script contains: #!/bin/ksh... (1 Reply)
Discussion started by: racbern
1 Replies

3. Shell Programming and Scripting

facing problem in starting a process in background using shell script.

hey all, i am working on sun solaris machine and i want to start a process in background using shell script (actually i wanna start tomcat server using shell script). please dont tell me that append a & at last because this is not working in the shell script. i have also used nohup and... (8 Replies)
Discussion started by: dtomar
8 Replies

4. UNIX for Dummies Questions & Answers

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... (1 Reply)
Discussion started by: teigipo
1 Replies

5. Shell Programming and Scripting

Background and Foreground of a process within a script

I'm not sure if it is even possible but I figured if it was someone here would know how to do it... I am running a script which starts a bunch of processes in the background but there is one process I would like to bring back to the foreground when complete. Unfortunately the process that I... (2 Replies)
Discussion started by: ctruhn
2 Replies

6. Shell Programming and Scripting

Background Process.

How to create a backgrond processes ? (5 Replies)
Discussion started by: anupdas
5 Replies

7. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

8. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

9. Shell Programming and Scripting

Running Shell Script in the cron, background process

Hi, i was looking for an answer for some trouble im having runing a script in the cron, thing is, that when i run it manually it works just fine. But when cron runs it, it just doenst work. I saw a reply on a similar subject, suggesting that the . .profile worked for you, but im kind of... (9 Replies)
Discussion started by: blacksteel1988
9 Replies

10. Shell Programming and Scripting

Make background process interact with fg process

Hi, I have written a menu driven shell script in which as per the choice, I run the another script on background. For eg: 1. get info 2)process info 3)modify info All the operations have different scripts which i schedule in background using &. However I wish to display the error... (0 Replies)
Discussion started by: ashima jain
0 Replies
NDPMON(8)						      System Manager's Manual							 NDPMON(8)

NAME
ndpmon - Neighbor Discovery Protocol Monitor SYNOPSIS
ndpmon [ -i interfacename ] [ -f configfile ] [ -d dtd_file ] [ -F filter ] [ -n number ] [ -L ] [ -v ] [ -h ] [ -d dtd_file ] [ -g neighbor_file ] DESCRIPTION
NDPMon is a monitoring software for ipv6 Neighbor Discovery. It syslogs activity and reports by email malicious ND message. NDPMon uses libpcap to listen for icmp6 packets and libxml2 to use configuration and neighbor cache files. The -i flag is used to change the default interface eth0. The -f flag is used to change the path of the configuration file. The default is /etc/ndpmon/config_ndpmon.xml The -e flag is used to change the path to the DTD file for the configuration file. The default is /etc/ndpmon/config_ndpmon.dtd The -n flag uses libpcap to specify a limited number of packet to capture. The -F flag allows one to change the default icmp6 filter. The -L flag is used to disable syslog and mail reports. This is used to do a learning phase and constitue the neighbor cache. The -v is used to enable the DEBUG mode. The -d flag is used to change the path to the DTD file for the neighbor cache. The default is /var/lib/ndpmon/neighbor_list.dtd The -g flag is used to change the path to the neighbor cache. The default is /var/lib/ndpmon/neighbor_list.xml Note that an empty neighbor_cache.xml file must be created before the first time you run ndpmon. NDPMon must be run with root rights to work. REPORT MESSAGES
Here's the list of the report messages generated by ndpmon: wrong couple MAC/IP Separately, the MAC and IP addresses are valid, but not as a couple. wrong router mac The ethernet address of the RA message is not specified in the configuration file. wrong router ip The ip address of the RA message is not specified in the configuration file. wrong prefix The prefix announced in the RA message is not specified in the configuration file. wrong router redirect The RD message does'nt come from a router specified in the configuration file. NA router flag The NA specifies a router but isn't one according to the configuration file. DAD DOS The NA answer to NS to avoid it to get an ip address. changed ethernet address The host switched to a new ethernet address. flip flop The ethernet address has changed from the most recently seen address to the second most recently seen address. reused old ethernet address The ethernet address has changed from the most recently seen address to the third (or greater) least recently seen address. SYSLOG MESSAGES
Here are some of the syslog messages; note that messages that are reported are also sysloged. new activity This ethernet/ip6 address pair has been announced for last time two months or more. new station The ethernet address has not been seen before on the link. ethernet broadcast The mac ethernet address of the host is a broadcast address. ip broadcast The ip address of the host is a broadcast address. bogon The source ip address is not local to the local subnet. ethernet mismatch The source mac ethernet address didn't match the address announced in option of the ND message. FILES
config_ndpmon.xml - contains settings which must be fill by the administrator neighbor_list.xml - neighbor cache: all neighbors known to be on the link SEE ALSO
arpwatch(8) ipv6(7), pcap(3), libxml(3). AUTHOR
Thibault Cholez and Frederic Beck for MADYNES Project, Loria, Fr. BUGS
Please send bug reports to frederic.beck@loria.fr or thibault.cholez@esial.uhp-nancy.fr November 2006 NDPMON(8)
All times are GMT -4. The time now is 12:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy