# Need Script Help...

**URL:** <https://community.unix.com/t/need-script-help/236515>\
**Category:** Shell Programming and Scripting\
**Created:** [March 30, 2009, 12:53pm UTC](https://community.unix.com/t/need-script-help/236515 "2009-03-30T12:53:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbxfan](https://community.unix.com/letter_avatar/gbxfan/32/6_22734026db12803ebb3e059622ac3534.png) [@gbxfan](https://community.unix.com/u/gbxfan)\
**Post date:** [March 30, 2009, 12:53pm UTC](https://community.unix.com/t/need-script-help/236515/1 "2009-03-30T12:53:38Z")

</div>

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](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!

---

<div class="post-metadata">

**Author:** ![joeyg](https://community.unix.com/user_avatar/community.unix.com/joeyg/32/780_2.png) [@joeyg](https://community.unix.com/u/joeyg)\
**Post date:** [March 30, 2009, 2:03pm UTC](https://community.unix.com/t/need-script-help/236515/2 "2009-03-30T14:03:31Z")

</div>

```nohighlight
( echo "login"; sleep 1; echo "password"; sleep 1; echo "http://xx.xx.xx.xx/probe_software.txt"; sleep 1 ) | telnet $i 24;

```

If I am reading this correct, only that 2nd part (telnet) will get executed.  
What are you trying to do here?

---

<div class="post-metadata">

**Author:** ![gbxfan](https://community.unix.com/letter_avatar/gbxfan/32/6_22734026db12803ebb3e059622ac3534.png) [@gbxfan](https://community.unix.com/u/gbxfan)\
**Post date:** [March 30, 2009, 2:14pm UTC](https://community.unix.com/t/need-script-help/236515/3 "2009-03-30T14:14:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joeyg](https://community.unix.com/user_avatar/community.unix.com/joeyg/32/780_2.png) [@joeyg](https://community.unix.com/u/joeyg)\
**Post date:** [March 30, 2009, 2:20pm UTC](https://community.unix.com/t/need-script-help/236515/4 "2009-03-30T14:20:43Z")

</div>

I would think to change

```nohighlight
( echo "login"; sleep 1; echo "password"; sleep 1; echo "http://xx.xx.xx.xx/probe_software.txt"; sleep 1 ) | telnet $i 24;

```

to

```nohighlight
( echo "login"; sleep 1; echo "password"; sleep 1; echo "http://xx.xx.xx.xx/probe_software.txt"; sleep 1 ; telnet $i 24);

```

---

<div class="post-metadata">

**Author:** ![gbxfan](https://community.unix.com/letter_avatar/gbxfan/32/6_22734026db12803ebb3e059622ac3534.png) [@gbxfan](https://community.unix.com/u/gbxfan)\
**Post date:** [March 30, 2009, 4:07pm UTC](https://community.unix.com/t/need-script-help/236515/5 "2009-03-30T16:07:51Z")

</div>

I will try it and let you know how it goes. I am SO GRATEFUL for any help or ideas!! THANKS for your TIME!!! Dale

---

<div class="post-metadata">

**Author:** ![gbxfan](https://community.unix.com/letter_avatar/gbxfan/32/6_22734026db12803ebb3e059622ac3534.png) [@gbxfan](https://community.unix.com/u/gbxfan)\
**Post date:** [March 30, 2009, 5:27pm UTC](https://community.unix.com/t/need-script-help/236515/6 "2009-03-30T17:27:32Z")

</div>

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?
