SUMMARY: Automated FTP

From: Michael Cook (mcook@uswest.com)
Date: Tue Oct 06 1998 - 23:21:36 CDT


Hello all,
    This is far & away the most answers I have received from a question here
(41 total). However, most ignored the sticky part of the question which was
how to complete this THROUGH A FIREWALL. I received a few nasty RTFM's, but
much excellent advice. I was able to make this happen with a Bourne script
(got the firewall password removed so that it is just a pass through from
the intranet to the internet), but from all the answers I received, Expect
would have filled this bill nicely, as would NCFTP client, and the use of
the .netrc file. If I were not able to get the firewall issue resolved
internally, Expect is what I would have used. However, please find my script
below, and a copy of the original post.
    Thanks a million to all who replied, and especially Karl Vogel whose
script I used as a model!!!
        Michael

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Original Post

Hello all,
    I have need to automate an ftp session through a firewall from our
corporate intranet nightly. I'm running a Sun Ultra 2 with Solaris 2.5.1,
y2k and recommended patches. Manually, the commands to complete this session
go as follows (bgate is a firewall between the intranet & the internet):

carousel% ftp bgate
Name (bgate:mcook): jdoe@ftp.outside.com
Password:
ftp> bin
ftp> get abc.dbm
ftp> get 123.dbm
ftp> get xyz.dbm
ftp> bye

Is this a task for Tcl/tk, Expect, or is there just some command line way to
execute this in cron?

    Thanks in advance & I will summarize,
        Michael

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Final Script

#!/bin/sh
#
# This script designed to be run in cron
# to automatically download database info
# to the current host.
#
# mcook@uswest.com
# Mon Oct 5 18:20:41 MST 1998
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Set the script's paths
#
PATH=/bin:/usr/sbin
export PATH
#
# Set the variables
#
firewall=bgate
remote=ftp.outside.com
uname=jdoe
password=pass
tmp=/tmp/ftp$$
target_dir=/home/jdoe
#
# Open the ftp session & get the files
#
cd $target_dir
echo "open $firewall
user $uname@$remote $password
verbose
type binary
get abc.dbm
get 123.dbm
get xyz.dbm
quit" | ftp -in > $tmp 2>&1
#
# The next line can be used to mail the
# results to an RP
#
#mailx -s "FTP results" mcook@uswest.com < $tmp
#
# Clean Up - Set ownerships
#
rm $tmp
chown jdoe *.dbm
chgrp staff *.dbm
exit 0
#
# End



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