Does anyone know what this means?
Occurring very intermittently.
send: spawn id exp3 not open while executing
"send "yes\n"
(file "/home/SFTPXFER/TOA/toageneric.expect" line 18)
Below is a copy of the script
Line 18 --> send "yes\n"
#!/usr/local/bin/expect -f
set timeout 30
proc timeStamp {} {
global tcl_version
if {$tcl_version >= 7.5} {
# "clock" command requires Tcl v7.5 or greater
# internal routine a little fasterthan making a system call
set stamp [clock format [clock seconds] -format %Y-%m-%d,%T]
} else {
# fall back to standard UNIX system call
set stamp [exec /bin/date +%Y-%m-%d,%T]
}
return $stamp
}
puts "[timeStamp]\n"
spawn sftp xxxxxxxxx.com
expect "Are you sure you want to continue"
send "yes\n"
expect "xxxxxxxxxxxxxxxxxx.com s password:"
send "xxxxxxxxxx\n"
expect "sftp>"
send "lcd /BRC/TOA\n"
expect "sftp>"
send "put BRCUPDATEFE_0120_1630.zip to_toa/inventory_upload/BRCUPDATEFE_0120_1630.zip\n"
expect "sftp>"
send "quit\n"
puts "[timeStamp]\n"
exit
I found the two below threads, but still not understanding the issue.
http://expect.sourceforge.net/FAQ.html#q64
• Why do I get "invalid spawn id"?
Subject: Why do I get "invalid spawn id"
In article <53ggqe$hag@xxxxxxxxxxxxx> khumbert@xxxxxxxxxxxxx writes:
I am trying to write a general looping procedure that will handle
many cases that have similar prompt sequences. The function and one
call are below.
The problem is that when the "looping" function is called I get an
"invalid spawn id(5) while executing "expect $exp1 {send -s "$send1}
timeout {continue}". I only have one spawn in the entire program
(a telnet session). I've tried setting a spawn_id variable for the
telnet spawn and then setting spawn_id to that variable in "looping",
but no dice, same error.
Any ideas? Thanks in advance for any suggestions!!!
Kelly Humbert
proc looping {exp1 exp2 send1 send2} {
global max_tries ### 5 ###
set tries 0
set connected 0
set timeout 60
while {$tries <= $max_tries && $connected == 0} {
incr tries
expect {
$exp1 {send -s $send1}
timeout {continue}
}
expect {
">? " {send -s "\n"}
timeout {continue}
}
expect {
$exp2 {incr connected;send -s $send2}
timeout {continue}
}
}
return $tries
};
What's going on is that the spawned process has closed the connection. When Expect detects this, it matches the "eof" pattern, and the spawn id is marked "invalid". However, you aren't testing for "eof", so the next command in your script finds the invalid spawn id, hence the complaint.
If you want to find out where the eof is occurring, enable Expect's diagnostic mode - Expect will get very chatty about what it is doing internally.
You can handle eof in all your expect statements by add a single expect_before/after command to your script.
Don<
http://www.nist.gov/msidstaff/libes>
[
http://expect.nist.gov/art/bann01.gif]
• Why do I get "spawn id XXX not open?"
This is the same problem as the previous question. The only difference is is that the error message changed to "not open" in Expect 5.31+. (This wasn't a gratuitous change; rather it was a consequence of the shift to using Tcl channels - now Tcl does the checking and hence generates the error message.)
Don<
http://www.nist.gov/msidstaff/libes>
Thank You
_____
Paul Steinmetz
IBM i Systems Administrator
Pencor Services, Inc.
462 Delaware Ave
Palmerton Pa 18071
610-826-9117 work
610-826-9188 fax
610-349-0913 cell
610-377-6012 home
psteinmetz@xxxxxxxxxx
http://www.pencor.com/
As an Amazon Associate we earn from qualifying purchases.