#!/bin/bash # ftpget - -Given an ftp-style URL, unwraps it and tries to obtain the # file using anonymous ftp. setglobal anonpass = ""$LOGNAME@$[hostname]"" if test $Argc -ne 1 { echo "Usage: $0 ftp://..." > !2 exit 1 } # Typical URL: ftp://ftp.ncftp.com/unixstuff/q2getty.tar.gz if test $[echo $1 | cut -c1-6] != "ftp://" { echo "$0: Malformed url. I need it to start with ftp://" > !2; exit 1 } setglobal server = $[echo $1 | cut -d/ -f3] setglobal filename = $[echo $1 | cut -d/ -f4-] setglobal basefile = $[basename $filename] echo $(0): Downloading $basefile from server $server ftp -np << """ open $server user ftp $anonpass get "$filename" "$basefile" quit """ if test $Status -eq 0 { ls -l $basefile } exit 0