Expect-Simple - getting error when spawn telnet $host $portnum

Posted on Sun Mar 4 12:07:00 2007 by sunnyvu
getting error when spawn telnet $host $portnum
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. So I try this:
spawn telnet "router1-mr 2036"
send "\r"
expect "Password"
send "00\r"
expect "-"
send "command\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 27)

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? Thanks in advance.
Write a response