Summary: Automatic ftp script

Bob Woodward (bobw@www.filmworks.com)
Fri, 11 Apr 1997 15:44:52 -0700

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

Thanks to:
Keith.Willenson@sunny.health.state.mn.us (Keith Willenson)
"Karl E. Vogel" <vogelke@c17.wpafb.af.mil>
"Eric J. Ostrander" <ejo@astro.phys.cmu.edu>
Rasana Atreya <atreya@library.ucsf.edu>
John Ballard <johnb@ocean.washington.edu>
boss@netcom.com (Todd Boss)
Reto Lichtensteiger <rali@meitca.com>
fpardo@tisny.com (Frank Pardo)
Susan Feng <sfeng@CAST.Stanford.EDU>
Jeff Newton <jeff@datapark.com>
Patrick Daloze <patdal@sisca.qc.ca>
Erick Cedeņo <erickc@sonitel.com>
"William L. Hamlin" <whamlin@connetsys.com>
cmconwa@sandia.gov (Christopher M. Conway)
Jon Anderson <jon.anderson@gs.com>
Jay Lessert <jayl@latticesemi.com>
David Neal <dneal@ix.ngccorp.com>
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:
ftp://ftp.cmu.nist.gov/pub/expect (cmu is incorrect but I knew they
meant cme)
ftp://ftp.cme.nist.gov/pub/expect
www.sunukug.org/steve_kilbane/reviews/expect.html
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 some.host.name
user username password-for-username
verbose
type binary
put local-file remote-file
quit" | ftp -in > /tmp/ftp.logfile.$$ 2>&1

*******************************************************************
#!/bin/sh
#
# sample automatic ftp script to dump a file
ftp -v -n $host << EOF
user $login_name $password
prompt
cd $dir
put $file
quit
EOF

************************************
!/bin/sh
#
#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
fi
#
# Go and get it!
#
file="$1"

#
# 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
host

**************************************

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 (bobw@filmworks.com)
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 "http://www.filmworks.com".