[SLE] Unattended FTP sessions
Dear all, my idea to make an unattended FTP session looked something like this: #!/bin/sh ftp -n $remote_site cat << END user mylogin pass mypass [ more commands here ] END But it stops when it connects to the remote server... so I must type the user and passwd information... I'm sure there must be a better way (wget does not fit my needs :-) ) but I remember seeing such unattended FTP sessions some time (years) ago... Any suggestions are welcomed! Martin -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
Martin Mielke wrote:
Dear all,
my idea to make an unattended FTP session looked something like this:
#!/bin/sh
ftp -n $remote_site
cat << END
user mylogin pass mypass
[ more commands here ]
END
But it stops when it connects to the remote server... so I must type the user and passwd information...
I'm sure there must be a better way (wget does not fit my needs :-) ) but I remember seeing such unattended FTP sessions some time (years) ago...
Any suggestions are welcomed!
Martin
Hi Martin, well I cannot go round not to tell RTFM. have a look into "man ftp". There is a ".netrc" file in the users $HOME, or rather you're supposed to create it. When you do "ftp foo.bar.com", the default user and pw for foo.bar.com are in that file, thus not requiring authentication anymore. With that, you can script your download with a simple file: myfile= ---8<--- binary cd /pub/linux/whatever lcd ~/download get foo.bar.tar.gz quit ---8<--- ftp < myfile will do the work. .netrc may look like: machine ftp.foo.de login juergen.braukmann password xxxxxxx default login anonymous password juergen.braukmann@foo.bar.de enjoy! Juergen PS: .netrc should be set to 600 that *only* you can read it! -- =========================================== __ _ Juergen Braukmann juergen.braukmann@gmx.de| -o)/ / (_)__ __ ____ __ Tel: 0201-743648 dk4jb@db0qs.#nrw.deu.eu | /\\ /__/ / _ \/ // /\ \/ / ===========================================_\_v __/_/_//_/\_,_/ /_/\_\ -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
On Tue, Aug 29, 2000 at 04:53:30PM +0200, Martin Mielke wrote:
#!/bin/sh
ftp -n $remote_site cat << END user mylogin pass mypass END
But it stops when it connects to the remote server... so I must type the user and passwd information...
ftp -n $FTPHOST << END user mylogin mypass ls END -- Darren Wyn Rees merlin@netlink.co.uk ASK your ISP to ADD the NEW england.* Newsgroups http://www.england.news-admin.org/accessfaq.html -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
There's two ways to do this. Either use the ftp client's .netrc file, or use expect. .netrc is simple but might not do quite what you want, depending on how complex the job is. See the ftp man page. Expect is a wonderful tool which will do exactly what you want. It's based on the Tcl scripting language, so if you don't know that you'll be in for a tough time. On the other hand Tcl is a great language to know. What you want to do seems pretty standard. I would guess that if you ask on the comp.lang.tcl newsgroup someone will already have an expect script to do it.
my idea to make an unattended FTP session looked something like this:
#!/bin/sh
ftp -n $remote_site
cat << END
user mylogin pass mypass
[ more commands here ]
END
But it stops when it connects to the remote server... so I must type the user and passwd information...
I'm sure there must be a better way (wget does not fit my needs :-) ) but I remember seeing such unattended FTP sessions some time (years) ago...
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
participants (4)
-
fountai@hursley.ibm.com
-
juergen.braukmann@ruhr-west.de
-
martinm@people-com.com
-
merlin@netlink.co.uk