Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Telnet to a single Server Multiple Times.

Status
Not open for further replies.

Neelimaix

Technical User
Jun 29, 2005
23
US
Hi all ,
I am trying to write a script to telnet to a single server multiple time ..
i am able to login once .but the loop doesnt seem to be workin . can anyboy help me in this regard.

my Expect script :
cat telnettest
#!/usr/local/bin/expect -f
spawn telnet lilo.sanjose.hgst.com
expect "Name"
send "anilsaka\r"
expect "Password:"
send "*****\r"
interact

My Shell Script :
#!/usr/bin/ksh
i=0
while [ $i -lt 4 ]
do
`expect telnettest`
i=$[$i+1]
done

 
i=$[$i+1]
I'd try this instead:
i=$((i+1))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Actually for the Korn shell, the cool way is...
Code:
(( i += 1 ))
Hope this helps.
 

Neelimaix: do you know where the loop get stucked? My bet would be the telnet session itself. Do you close the telnet session, or it just keeps waiting for commands?

--Trifo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top