telnet expect script error
- From: "powah" <wong_powah@xxxxxxxx>
- Date: 14 Nov 2005 15:10:46 -0800
This is my expect script to telnet. Sometimes it works and sometimes
it fail.
Why and how to fix it?
set timeout -1
exp_internal 1
set res [spawn telnet $server]
expect "login:" { send "$user\r" }
expect "Password:" { send "$pass\r" }
expect {
"Last login" {
puts "..Connected ! "
sleep 0.5
}
"Login failed" {
puts "**FAILED** to TELNET to $server using ($user,$pass) "
exit
}
}
When the script fails, the error message is:
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Fedora Core release 3 (Heidelberg)
Kernel 2.6.9-1.667 on an i686
login: john
Connection closed by foreign host.
ERROR INFO:
expect: spawn id exp6 not open
while executing
"expect -nobrace {Last login} {
info_print " "
info_print "..Connected ! "
sleep 0.5
} {Login failed} {
info_print "**FAILED** ..."
invoked from within
"expect {
"Last login" {
info_print " "
info_print "..Connected ! "
sleep 0.5
}
"Login failed" {
info_print "**FAILED** to..."
(procedure "run_remote" line 26)
invoked from within
.
- Follow-Ups:
- Re: telnet expect script error
- From: Don Libes
- Re: telnet expect script error
- Prev by Date: How to properly combine evaulation and variable?
- Next by Date: Re: Problems sending PDF attachment (mime)
- Previous by thread: How to properly combine evaulation and variable?
- Next by thread: Re: telnet expect script error
- Index(es):
Relevant Pages
|