Summary: Automatic ftp script

From: Bob Woodward (
Date: Fri Apr 11 1997 - 17:44:52 CDT

Talk about RESPONSE!!!! I've now got a number of ways to do exactally what
I wanted to do.

Thanks to: (Keith Willenson)
"Karl E. Vogel" <>
"Eric J. Ostrander" <>
Rasana Atreya <>
John Ballard <> (Todd Boss)
Reto Lichtensteiger <> (Frank Pardo)
Susan Feng <sfeng@CAST.Stanford.EDU>
Jeff Newton <>
Patrick Daloze <>
Erick Cedeņo <>
"William L. Hamlin" <> (Christopher M. Conway)
Jon Anderson <>
Jay Lessert <>
David Neal <>
and the many others who will still be sending suggestions. (This list is
so GREAT!)

Original request:
Hi SM's. I've got a requirement to make a system that will automatically
ftp files from our system to a business partner of ours. What I'm looking
for is a way that I can ftp a file from a shell script. I don't need error
checking of seeing if a file exists because I'll end up using a program to
create the script, execute it, and log the transaction.

What I need is something like TIP does for a modem only for FTP.
Suggestions? I will summarize.
The responses boil down to the following methods:

1. Use 'expect' to create interactive responses. Some of the references to
go for information include: (cmu is incorrect but I knew they
meant cme)
  And the O'Reilly Book "Exploring Expect" by Don Libes.

2. The use of 'echo' and piping to the ftp process. Examples included:

echo "open
user username password-for-username
type binary
put local-file remote-file
quit" | ftp -in > /tmp/ftp.logfile.$$ 2>&1

# sample automatic ftp script to dump a file
ftp -v -n $host << EOF
user $login_name $password
cd $dir
put $file

#Need the following entry in ~/.ftprc file to run this script:
# machine <anonymous ftp site> login ftp password <yourlogin>@yourdomain
if [ $# -le 0 ]; then
        echo "Usage: get_ftp_file <file> "
        exit 1
# Go and get it!

# Replace /tmp with a directory name where you want to put your ftp file
cd /tmp
echo "
get $file
quit" | ftp -i <ftp site>

$ echo "user username passwd\n binary\n put sourcefile destfile\n" | ftp -n


3. Use Perl after getting the file libwww.

Thanks to everyone. I'll probably set up and try the first two to see
which would be easier to maintain and keep documented. The Perl option
I'll probably not try because I'm not that experienced with Perl, yet.

Bob Woodward, Seattle FilmWorks (
Data Processing Department (206) 281-1390 ext. 475

Visit our Web Site to learn about getting your pictures via downloads on
the Internet!
Point your browser to "".

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:50 CDT