I am trying to write a simple script to update clients that are probes with new firmware software, but everytime I run it, it doesn't wait for the download it just runs through the list of clients without finishing the download. I tried to use wait on the pid and I could use sleep for some crazy amount of time and that works, but I would like it to be more intelligent and let it finish one and then move to the next.
I am running it from the command line as follows:
sh programname file1
# command line format:
#
# sh programname [FILE1]
#
# where FILE1 is an input file containing a single list of ip's (hosts)
#
PID="${$}" #Current process id to be used
date 2>&1
for i in `cat $1`
do
if ping $i 64 1 | grep -s "100%"
then
echo $i": not on the Network!" >> REDO_PROBE
else
( echo "login"; sleep 1; echo "password"; sleep 1; echo "http://xx.xx.xx.xx/probe_software.txt"; sleep 1 ) | telnet $i 24;
fi
done
any ideas on how I can script this so it waits until the first process on the probe finishes before it moves to the next? I was also thinking about using touch file to have it wait but I can't find anything to copy to do that or know how to program it. Any help appreciated. Thanks!
Thanks for responding. There is a software update on another server so I am trying to send login/password to the probe that needs the update and then send the link where the update is so the probe can grab the update. It actually kind of works but when the download starts for one probe it never finishes, it just stops and goes to the next client and starts the download and stops it (interupts it actually) then it goes to the next client and so on and so on. Its like it needs a wait statement which would work if I made some long timeframe, but then I would be held to the wait time and would rather be held by the process...I hope this helps.
Mmmm. Well, its stopping, but now its not giving the login information. I tried to move some of that line around and the script is not able to deliver the login and password for it to continue. Any ideas?