There are lots of ways to do this.
A here document as suggested above is useful, as is wget etc.
Slightly better (but only slightly) is to use a .netrc file
here's a basic .netrc (see man netrc) for normal ftp.
----$HOME/.netrc 600 perms --
machine somewhere.com login mylogin password mypass macdef
init
lcd /appl/fp/merge
cd /appx/data/50/XFR/Data
put artrx.tab TRXFER.dat
quit
machine someothermachine.org login whatever password pass macdef
init
hash
bin
prompt off
machine yetanother ...
The first example (somewhere.com) logs in, changes to a local directory /appl/fp/merge, then changes to /appx/data/50/XFR/Data on the server and "puts" a file.
With this in place, the command "ftp somewhere.com" will do the "put". You could set "prompt off" and use "mput" or "mget" in the .netrc also.
The second just logs you in to "someothermachine.org" , turns on hash, etc. and then you can type your own commands.
You can fully script more complex things with:
#!/bin/ksh
echo "machine somewhere.com login mylogin password mypass
macdef init" > $HOME/.netrc
echo "lcd /appl/fp/merge" >> $HOME/.netrc
echo "cd /appx/data/50/XFR/Data" >> $HOME/.netrc
for i in *.tab
do
echo "put $i ${i%tab}.dat" >> $HOME/.netrc
done
echo "quit" >> $HOME/.netrc
echo " " >> $HOME/.netrc
# always end a macdef with a blank line
chmod 600 $HOME/.netrc
ftp somewhere.com
Kermit has a better ftp scripting capability
http://www.columbia.edu/kermit/ftpclient.html
http://www.columbia.edu/kermit/ftpscripts.html
and so does ncftp and I think lftp
Of all the ways, I prefer Perl - see
http://aplawrence.com/Unixart/perlnetftp.html for the why and the how.
--
Tony Lawrence
http://aplawrence.com