Hi All, I have been trying to get an Expect program to communicate with a Remote Power Switch which will eventually log in, and then turn on/off certain outlets. For some reason, I can't get through the log in procedure with this Switch. When you first spawn the telnet, you get the Switch info/header, and then a Password prompt, but for some
strange reason, the first time you send the password, it gets ignored, and repeats the whole header.. ok, but I try to send the password again, and the Expect script sits there and eventually times out.. I ripped out the log in procedure and made it very simple just to try to get through the log in procedure to get to the main menu of the switch, even this small piece of code doesn't work... So, I'm a bit
frustrated.. Maybe it's been too much for my eyes and it's a trivial problem but here is the piece of code... Can anyone help make heads or tales of why I can't get past this darn point. When the log in procedure is successful, I should get the Enter > prompt, but I can't get here. Thanks in advance...
#!/opt/ActiveTcl-8.4/bin/tclsh
package require Expect
log_user 1
exp_internal 1
set timeout 20
spawn telnet 1XX.1XX.1XX.149
expect "*Password > "
after 1000
send "PASS\\r"
expect "*Enter > "
And here is the output I get with the debug levels turned up:
# ./johnTest
spawn telnet XXX.112.XXX.149
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {27205}
expect: does "" (spawn_id exp4) match glob pattern "*Password > "? no
Trying XXX.112.XXX.149...
expect: does "Trying XXX.112.XXX.149...\r\n" (spawn_id exp4) match
glob pattern
"*Password > "? no
Connected to XXX.112.XXX.149.
Escape character is '^]'.
expect: does "Trying xXx.112.XXX.149...\r\nConnected to XXX.112.XXX.
149.\r\nEsc
ape character is '^]'.\r\n" (spawn_id exp4) match glob pattern
"*Password > "?
no
iPal Version 2.3e
Please Enter The Password >
expect: does "Trying XXX.112.XXX.149...\r\nConnected to XXX.112.XXX.
149.\r\nEsc
ape character is '^]'.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\
r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\niPal Version 2.3e\r\n
\r Please
Enter The Password > " (spawn_id exp4) match glob pattern "*Password >
"? yes
expect: set expect_out(0,string) "Trying XXX.112.XXX.149...\r
\nConnected to XXX
.112.XXX.149.\r\nEscape character is '^]'.\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\
r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r
\niPal Versio
n 2.3e\r\n\r Please Enter The Password > "
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "Trying XXX.112.XXX.149...\r\nConnected
to XXX.1
12.XXX.149.\r\nEscape character is '^]'.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r
\n\r\n\r\
n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\niPal
Version
2.3e\r\n\r Please Enter The Password > "
send: sending "PASS\r" to { exp4 }
expect: does "" (spawn_id exp4) match glob pattern "*Enter > "? no
PASS
expect: does "PASS\r\n" (spawn_id exp4) match glob pattern "*Enter >
"? no
expect: timed out
#