#!/usr/local/bin/expect -f # Jim Dutton - 10/12/1998; 11/12/1998 set userid [lindex $argv 0] set password [lindex $argv 1] set jclfile [lindex $argv 2] set currdate [lindex $argv 3] set basedir "/var/samba/MFtransfer/$userid/submit" set timeout 30 log_file "$basedir/submit.log.$currdate" set time [timestamp -format %c] send_user "Log start - $time\n" if {$argc < 4} then {send_user "\n---not enough EXPECT arguments---\n";exit 1} spawn ftp expect "Name*:" send "$userid\r" expect "530*Userid*system*ftp>.*" { send_user "\n---invalid userid---\n" exit 1 } timeout { send_user "\n---timed out on USERID---\n" exit 1 } Password: send "$password\r" expect "530 Password*failed." { send_user "\n---missing password---\n" exit 1 } "530*Password*userid*failed." { send_user "\n---invalid password---\n" exit 1 } timeout { send_user "\n---timed out on PASSWORD---\n" exit 1 } "ftp> " send "site submit\r" expect "?Invalid command." { send_user "\n---SITE SUBMIT command garbled---\n" exit 1 } timeout { send_user "\n--timed out after SITE SUBMIT---\n" exit 1 } "ftp> " #expect "ftp> " send "put $basedir/$jclfile $jclfile\r" expect "ftp:*No such file*ftp> " { send_user "\n---missing or incorrect file to send---\n" exit 1 } timeout { send_user "\--timed out after PUT---\n" exit 1 } "ftp> " #expect "ftp> " send "quit\r" expect eof exit 0