[NTLUG:Discuss] any experience with an expect script to run ftp session?
Chris Cox
cjcox at acm.org
Tue Aug 7 23:23:59 CDT 2001
Your getting a timeout "expect"ing for the ftp> prompt
while the mget is taking place. Adjust the timeout
value to infinity (or a reasonably large value) if you have
to before you do the mget.
Fred James wrote:
>
> 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...
>
> ------------------------------------------------------------------------------------------
> #!/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