January 2004
Intermediate to advanced
368 pages
7h 25m
English
This is the partner to Script #81, ftypsyncup, and it proves to be quite a bit simpler. It utilizes the ftp mget command to automatically retrieve the contents of all files in the remote directory, copying them one by one to the local system.
#!/bin/sh # ftpsyncdown - Given a source directory on a remote FTP server, # downloads all the files therein into the current directory. tempfile="/tmp/ftpsyncdown.$$" trap "/bin/rm -f $tempfile" 0 1 15 # zap tempfile on exit if [ $# -eq 0 ] ; then echo "Usage: $0 user@host { remotedir }" >&2 exit 1 fi user="$(echo $1 | cut -d@ -f1)" server="$(echo $1 | cut -d@ -f2)" echo "open $server" > $tempfile echo "user $user" >> $tempfile if [ $# -gt 1 ] ...Read now
Unlock full access