Path: utzoo!attcan!uunet!shelby!bu.edu!snorkelwacker!usc!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!otter.hpl.hp.com!hpltoad!jperry!jp From: jp@hplb.hpl.hp.com (Julian Perry) Newsgroups: alt.sources Subject: Recursive ftp from another Unix machine.... Keywords: ftp recursive Message-ID: <1990Jul12.155536.19483@hplb.hpl.hp.com> Date: 12 Jul 90 15:55:36 GMT Sender: news@hplb.hpl.hp.com (Usenet News Administrator) Reply-To: jp@hplb.hpl.hp.com Organization: Hewlett-Packard Labs, Bristol, UK Lines: 151 Nntp-Posting-Host: jperry.hpl.hp.com Here's a shell script which connects to a remote machine and pulls in (in binary mode) all files (recursively downwards) from the named directories. It's really handy for example: getrftp uunet.uu.net comp.sources.unix/volume14 If the ftp fails part way through it will just carry on without bothering to transfer files it already has. It will only talk to other Unix ftp servers. Comments/suggestions/defects? Jules -- E-MAIL: jp@hplb.hpl.hp.com || jp@hpl.hp.co.uk IN-REAL-LIFE: Julian Perry ORGANISATION: Hewlett-Packard Laboratories, Bristol ADDRESS: Filton Road, Stoke Gifford, Bristol, England, BS12 6QZ TELEPHONE: +44 272 799910 x 24019 #---------------------------------- cut here ---------------------------------- # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by Julian Perry on Thu Jul 12 16:46:32 1990 # # This archive contains: # getrftp # # Existing files will not be overwritten. # Error checking via wc(1) will be performed. # Error checking via sum(1) will be performed. LANG=""; export LANG PATH=/bin:/usr/bin:$PATH; export PATH if sum -r /dev/null 2>&1 then sumopt='-r' else sumopt='' fi if test -f getrftp then echo Ok to overwrite existing file getrftp\? read answer case "$answer" in [yY]*) echo Proceeding;; *) echo Aborting; exit 1;; esac rm -f getrftp if test -f getrftp then echo Error: could not remove getrftp, aborting exit 1 fi fi echo x - getrftp cat >getrftp <<'@EOF' #!/bin/sh # # Script to get directories of files (recursively) from a Unix # ftp server. # # Usage: getrftp [ ...] # # File: getrftp # Author: Julian Perry (jp@hplb.hpl.hp.com) # Date: 90/07/12 # Revision: 1.0 # USER=ftp PASSWORD=`hostname` VERBOSE=-v if [ $# -lt 2 ] then echo "usage: $0 [ ...]" exit 1 fi HOST=$1 ROOT=`pwd` TMPFIL="/tmp/grftp.$$" trap "rm -f $TMPFIL; trap '' 0; exit" 0 1 2 13 15 shift for DIR in $* do ftp -v -g -i -n $HOST <