[NTLUG:Discuss] any experience with an expect script to run ftp session?
Fred James
fredjame at concentric.net
Tue Aug 7 22:13:16 CDT 2001
Has any one had any experience with an expect script to run ftp session?
I have one that starts, gets maybe 3 of the 50+ files it should, and
then quits with no apparent error.
I tested by
(1) doing manually everything the script does and the session worked
fine.
(2) manually kicking off the expect script and it failed just as noted
above.
In case there are any takers, I have attached an ASCII text file called:
sample_script
--
...make every program a filter...
-------------- next part --------------
#!/usr/bin/expect -f
# ftp_ppdv
#
cd path_to_target_directory_on_local_host
spawn /usr/bin/ftp -i remote_host
while 1 { expect {
"Name\*: " {send "remote_username\r"}
"Password:" {send "remote_user_password\r"}
"ftp> " {break}
"failed" {send_user "Can't log in.\r"; exit 1}
timeout {send_user "Timeout problem.\r"; exit 2}
}}
send "cd path_to_source_directory_on_remote_host\r"
expect "ftp> " {send "mget \*\r"}
expect "ftp> " {send "bye\r"; send_user "\r"}
exit 0
More information about the Discuss
mailing list