[NTLUG:Discuss] any experience with an expect script to run ftp session?
Fred James
fredjame at concentric.net
Wed Aug 8 08:05:41 CDT 2001
Thank you for your reply - that did the trick.
Chris Cox wrote:
>
> 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
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
--
...make every program a filter...
More information about the Discuss
mailing list