04-01-2008
6,
0
Join Date: Mar 2008
Last Activity: 11 April 2008, 12:46 AM EDT
Posts: 6
Thanks Given: 0
Thanked 0 Times in 0 Posts
Thank you for the reply. Hopefully with practice I won't have to ask such basic questions.
The thought I have in my head is a count
I have been playing with different ones i have found online and I can't get them to work. I am sure it is me that is the problem.
The only purpose of the first script file is to cat the file device.txt and store the variable $device then export that to the second script file i call as a back ground process.
What I am hoping for but cannot get the syntax correct is
as the first script launches background processes it starts a count of how many it has started. Once it reaches 100 it either waits for all background processes to finish (preferable) then continues on. OR
it sleeps for 120 seconds before firing off the next hundred.
As for the cat the output redirect is inside the script that is called
named devicev2
ip=`(host $device | awk ' /has/ {print $4}')`
if [ "$ip" ]
then
dns="$ip"
answer=`(ping -c 1 -q -w 2 -n $device 2>/dev/null | grep received | awk '{print $4}')`
if
[ $answer = 0 ];
then answer="NO"
else answer="YES"
fi
if
[ $answer = "YES" ];
then
routername=`(snmpget -t 2 -r 0 -Oqv -Os -v 2c -c (Read only community string) $device 2>/dev/null SNMPv2-MIB::sysName.0)`
if [ "$routername" = "" ];
then snmpread="NO"
routername="N/A"
else snmpread="YES"
fi
snmpwrite=`(snmpget -t 2 -r 0 -Oqv -Os -v 2c -c (Read Write community string) $device 2>/dev/null SNMPv2-MIB::sysName.0)`
if [ "$snmpwrite" = "" ];
then snmpwrite="NO"
else snmpwrite="YES"
fi
if [ "$snmpwrite" = "YES" ];
then
devicenumber=`(snmpwalk -v 2c -OQs -c (Read Write community string) $device 1.3.6.1.2.1.4.20.1.2 | grep $ip | awk ' /=/ {print $3}')`
interface=`(snmpwalk -v 2c -OQs -c (Read Write community string) $device 1.3.6.1.2.1.2.2.1.2 | grep -w ifDescr.$devicenumber | awk '/=/ {print $3}')`
else
interface="N/A"
fi
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface" >> device.log
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface"
else
snmpread="NO"
snmpwrite="NO"
interface="N/A"
routername="N/A"
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface" >> device.log
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface"
fi
else
dns="Not in DNS"
answer="NO"
snmpread="NO"
snmpwrite="NO"
interface="N/A"
routername="N/A"
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface" >> device.log
echo "$device,$routername,$dns,$answer,$snmpread,$snmpwrite,$interface"
fi
exit