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!

getting error when spawn telnet $host $portnum

Status
Not open for further replies.

SunnyVu

Technical User
Oct 30, 2006
3
US
Hi, I am new with Expect. I am trying to connect to the Equipment1 that connected to the Router1 port# 2036. In DOS telnet, I can just type "telnet router1-mr 2036", hit Enter, then Enter again, then it will prompt me password. to elaborate, after telnet and hit 1st Enter, it will display BLANK until I hit the 2nd Enter, then it prompt "Password?", then I enter "00" for password, then I and run any command. Not sure why, but this is how the equipment setup.

#!c:/expect/bin/expect.exe
#
spawn telnet "lsanca01-mr 2036"
expect_before
send "\r"
send "\r"
expect "Password"
send "00\r"


I got an ERROR:

spawn telnet router1-mr 2036
router1-mr 2036: No data record of requested type.
send: invalid spawn id (exp_spawn0)
while executing
"send "00\r""
(file "./test.exp" line 9)


I think the problem cause by that after telnet, it shows BLANK until I enter the 2nd time, then it prompts "Password:". Is there a work around for this? Something like if Nothing after spawn telnet, then send /r again so it can get to the password prompt? Thanks in advance.
 
try just spawn telnet router1-mr 2036 without the quotes
eg

#!c:/expect/bin/expect.exe
#
spawn telnet lsanca01-mr 2036
....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top