The script appears to have completed but the FTP process is listed as
<defunct> in the process list and the script simply hangs.
My knowledge of expect/tcl is somewhat limited but I have looked in
Exploring Expect which mentions things about wait --nowait. Is this
what I am looking for?
Thanks in Advance
Peter
Script Follows:
set exp_log "$env(EXP_LOG)"
set exp_remote_host "$env(EXP_REMOTE_HOST)"
set exp_file_list "$env(EXP_FILE_LIST)"
set exp_username "$env(EXP_USERNAME)"
set exp_userpass "$env(EXP_USERPASS)"
set exp_remotedir "$env(EXP_REMOTEDIR)"
set nowtime [timestamp -format %c]
log_file $exp_log
send_log "Logfile opened at: \$nowtime\n"
set timeout 60
spawn ftp $exp_remote_host
expect {
timeout {send_log "Timeout (spawn ftp)\n" ; exit 1}
"nknown" {send_log "Unknown Host\n" ; exit 1}
"Name*:" {}
}
send "$exp_username\r"
expect {
timeout{send_log "Timeout (pwd prompt)\n" ; exit 1}
"assword:"{}
}
send "$exp_userpass\r"
expect {
timeout {send_log "Timeout (logging in)\n" ; exit 1}
"530*>" {send_log "Login Failed\n" ; send "quit\r" ;
exit 1}
"ftp>" {}
}
send "cd $exp_remotedir\r"
expect {
timeout {send_log "Timeout (cd remotedir)\n" ; exit 1}
"501*>" {send_log "CD Failed\n" ; send "quit\r" ; exit
1}
"250*>" {}
}
send_log "Logged in and Ready\n"
set out [open $exp_file_list w]
send "dir\r"
expect {
timeout {send_log "Timeout (dir)\n" ; close $out ;
exit 1}
-re "^ftp>" {puts $out "Complete" ; close $out}
-re "^.*\r\n" {puts $out $expect_out(0,string) ;
exp_continue}
}
send "quit\r"
expect {
timeout {send_log "Timeout (logging out)\n" ; exit 1}
"221" {}
}
: The script appears to have completed but the FTP process is listed as
: <defunct> in the process list and the script simply hangs.
After an exp_close, you need to do an exp_wait to reap <defunct>
processes. This is necessary whenever a child process is killed.
I believe it's covered in Libes' Exploring Expect. The related
Unix system call, wait(), is covered in Stevens' "Advanced Programming
in the Unix Environment".
-=- D. J.
-=- dhag...@glatmos.com