From: dhirmes@hamp.hampshire.edu
Subject: re: automatic ftp via shell script
Organization: Hampshire College
Date: Wed, 14 Oct 1992 17:15:30 GMT

A few weeks ago, there was a discussion on possible ways to do automatic
FTP from a UNIX shell.  I found the following post and thought it might
be of help/interest...

dh
---------------------------------------------------------------------------

From: kko@fraser.sfu.ca (Samuel Ko)
Newsgroups: comp.binaries.ibm.pc.archives,etc.
Subject: A Unix Shell Script to Auto-Ftp MSDOS Files from Garbo's mirrors....

The following Unix shell script can help you auto-download Garbo's MSDOS 
files from its mirror site at wuarchive.wustl.edu ...

To use it ...
1) save this article as garboftp (or whatever name you prefer) ...
2) cut everything above #!/bin/sh ...
3) make this file executable ... i.e. chmod u+x garboftp
4) run the script ... garboftp directoryA file1 file2 directoryB file3 file4  

If your favorite Garbo mirror site is not wuarchive.wustl.edu, you can 
substitute the first two lines after the comment box with the host you 
prefer and the corresponding directory ... i.e.  

Host=                   Directory= 
archie.au               /micros/pc/garbo/pc/$1
nctuccca.edu.tw         /Garbo/pc/$1

Hope you like this ... And please send any comments, suggestions and 
flames to me ...

Samuel Ko (kko@sfu.ca)  aka: The Smart One ... 

-----------------------------------  Cut Here -------------------------------
#!/bin/sh
#######################################################################
#                                                                     #
#         garboftp ...                                                #
#         Shell script to auto-ftp MSDOS files from                   # 
#         /mirrors/garbo.uwasa.fi at wuarchive.wustl.edu ...          #
#                                                                     # 
#         Written by Samuel Ko (kko@sfu.ca) based on                  #
#         Jon Granrose's getfile ... Last-updated: 10/13/92 ...       #
#                                                                     #
#                                                                     #
#######################################################################

host=wuarchive.wustl.edu
directory=/mirrors/garbo.uwasa.fi/$1


if [ $# -lt 2 ]
then
	echo "Usage: $0 directoryA file1 file2 ... directoryB file3 file4 ..."
        echo "Example: $0 pd2 moder16.zip  ts tsfaq30.zip"
	exit 1
else

(
	echo user anonymous -$USER@$host
	echo hash
	echo binary
	echo cd $directory
while test -n "$1"
do
   case $1 in
	aninmation)     echo cd .. ; echo cd animation;;
	arcers) 	echo cd .. ; echo cd arcers;;
	arcutil) 	echo cd .. ; echo cd arcutil;;
	assembler) 	echo cd .. ; echo cd assembler;;
	astronomy) 	echo cd .. ; echo cd astronomy;;
	autocad) 	echo cd .. ; echo cd autocad;;
	batchutil) 	echo cd .. ; echo cd batchutil;;
	bbs) 	        echo cd .. ; echo cd bbs;;
	binedit) 	echo cd .. ; echo cd binedit;;
	bootutil) 	echo cd .. ; echo cd bootutil;;
	business) 	echo cd .. ; echo cd business;;
	c) 		echo cd .. ; echo cd c;;
	cad)            echo cd .. ; echo cd cad;;
        calendar) 	echo cd .. ; echo cd calendar;;
	cd)     	echo cd .. ; echo cd cd;;
        cmd4dos)        echo cd .. ; echo cd cmd4dos;;
        cmdutil)        echo cd .. ; echo cd cmdutil;;
        comm)   	echo cd .. ; echo cd comm;;
	connect) 	echo cd .. ; echo cd connect;;
	database) 	echo cd .. ; echo cd database;;
	decode)         echo cd .. ; echo cd decode;;
        demo)           echo cd .. ; echo cd demo;;
        dirutil)        echo cd .. ; echo cd dirutil;;
        diskcopy)       echo cd .. ; echo cd diskcopy;;
        diskutil)       echo cd .. ; echo cd diskutil;;
        djgpp)          echo cd .. ; echo cd djgpp;;  
        doc?hard)       echo cd .. ; echo cd doc-hard;;
	doc?misc) 	echo cd .. ; echo cd doc-misc;;
	doc?net) 	echo cd .. ; echo cd doc-net;;
	doc?soft) 	echo cd .. ; echo cd doc-soft;;
	doshelp) 	echo cd .. ; echo cd doshelp;;
	editor) 	echo cd .. ; echo cd editor;;
	education) 	echo cd .. ; echo cd education;;
	educgames) 	echo cd .. ; echo cd educgames;;
	envutil) 	echo cd .. ; echo cd envutil;;
	exam)     	echo cd .. ; echo cd exam;;
	execomp) 	echo cd .. ; echo cd execomp;;
	filecopy) 	echo cd .. ; echo cd filecopy;;
	filefind) 	echo cd .. ; echo cd filefind;;
	filelist) 	echo cd .. ; echo cd filelist;;
	fileutil) 	echo cd .. ; echo cd fileutil;;
	fonts)  	echo cd .. ; echo cd fonts;;
	format) 	echo cd .. ; echo cd format;;
	gif) 		echo cd .. ; echo cd gif;;
        gifutil)        echo cd .. ; echo cd gifutil;;
	goldies) 	echo cd .. ; echo cd goldies;;
	graphics) 	echo cd .. ; echo cd graphics;;
	ham)    	echo cd .. ; echo cd ham;;
	hv)     	echo cd .. ; echo cd hv;;
	hypertext) 	echo cd .. ; echo cd hypertext;;
	keyboard) 	echo cd .. ; echo cd keyboard;;
	linguistics) 	echo cd .. ; echo cd linguistics;;
	link) 		echo cd .. ; echo cd link;;
	mail) 		echo cd .. ; echo cd mail;;
	math) 		echo cd .. ; echo cd math;;
        memacs)         echo cd .. ; echo cd meamcs;;
	memutil)        echo cd .. ; echo cd memutil;;
	menu) 		echo cd .. ; echo cd menu;;
	miscutil) 	echo cd .. ; echo cd miscutil;;
	net)    	echo cd .. ; echo cd net;;
	opus) 		echo cd .. ; echo cd opus;;
	pcmag) 		echo cd .. ; echo cd pcmag;;
	pd2)    	echo cd .. ; echo cd pd2;;
	plot) 		echo cd .. ; echo cd plot;;
	printer) 	echo cd .. ; echo cd printer;;
	programming) 	echo cd .. ; echo cd programming;;
	sb)             echo cd .. ; echo cd sb;;
        science)        echo cd .. ; echo cd science;;
	screen) 	echo cd .. ; echo cd screen;;
	sound) 		echo cd .. ; echo cd sound;;
        source)         echo cd .. ; echo cd source;;
	spreadsheet) 	echo cd .. ; echo cd spreadsheet;;
	stat)   	echo cd .. ; echo cd stat;;
	stock)  	echo cd .. ; echo cd stock;;
	sysinfo) 	echo cd .. ; echo cd sysinfo;;
	sysutil) 	echo cd .. ; echo cd sysutil;;
        termprog)       echo cd .. ; echo cd termprog;;
	termutil) 	echo cd .. ; echo cd termutil;;
	tex) 		echo cd .. ; echo cd tex;;
	ts) 		echo cd .. ; echo cd ts;;
	tsr) 	        echo cd .. ; echo cd tsr;;
	turboobj) 	echo cd .. ; echo cd turboobj;;
	turbopas) 	echo cd .. ; echo cd turbopas;;
	turbovis) 	echo cd .. ; echo cd turbovis;;
        txtutil)        echo cd .. ; echo cd txtutil;;
        unix)           echo cd .. ; echo cd unix;;
	util) 		echo cd .. ; echo cd util;;
	virus) 		echo cd .. ; echo cd virus;;
	*.*)		echo get $1;;
      esac
echo pwd
shift
done
	echo bye

) | ftp -n -v $host 

fi
Newsgroups: comp.unix.questions