ftp in background?

Stacy L Ramirez seaotter at athena.mit.edu
Fri Aug 3 09:41:46 AEST 1990


In article <Jul.27.09.36.11.1990.20837 at athos.rutgers.edu> masticol at athos.rutgers.edu (Steve Masticola) writes:
>
>I would like to ftp in several files from a remote site (using
>anonymous ftp). The site is busy during most daylight hours, and even
>when I can connect, the connection has been unreliable. Is there any
>utility that can transfer files in background, and will retry on a
>broken or uncompleted connection?
>
>Thanks for your help,
>- Steve (masticol at athos.rutgers.edu)

The following will not retry, but it should be simple to write a
second script to call this one and then check for the existence of the
desired fill until it exists or it has tried a certain number of times...

If you know the name of the site, the file, and the directory, I have
a shell script that will do the trick.  I call it gaf (for "get a file")
and use it thusly:

	% gaf site directory file1 file2 ... file6 > log.foo &

for example "% gaf pilot.njin.net /ftp-list ftp.list > log &" will get
the list of anonymous ftp sites stored at pilot in the directory ftp-list.
Actually the script I have is based on the script getfile found in that
directory -- it just accepts arguments for site and directory as well
as filename.  The file will be written to the user's site with the same name,
so care must be taken not to overwrite existing files.  The file log.foo
will contain the responses of the remote site and is useful if ftp fails
for whatever reason -- it will show if connection timed out, or whatever.

...and here it is...

PS - please IMPROVE this!  I didn't remember enough shell script to
do a really proper job at it, so it is UGLY!  Please fix it and email
me the improved version.  (It still WORKS, just inelegant.)

cut here ! cut here ! cut here ! cut here ! cut here ! cut here ! cut here

#!/bin/sh
#	Simple shell script to fetch a file
#
#	Syntax: gaf <site> <dir> <file> ...
#
#	based on "getfile" by Jon Granrose (odin at pilot.njin.net)
#

if [ $# -lt 3 ]
then
	echo "Usage: $0 <site> <dir> <file> ..."
	exit 1
fi

(
	echo user anonymous $USER

	echo hash
	echo binary

	echo cd $2

	if [ $# -ge 3 ]
	then
		echo get $3
	fi

	if [ $# -ge 4 ]
	then
		echo get $4
	fi

	if [ $# -ge 5 ]
	then
		echo get $5
	fi

	if [ $# -ge 6 ]
	then
		echo get $6
	fi

	if [ $# -ge 7 ]
	then
		echo get $7
	fi

	if [ $# -ge 8 ]
	then
		echo get $8
	fi

	echo bye

) | ftp -n -v $1

____Mike_Zraly____________________________________________________________
|	obligatory address	: c/o seaotter at athena.mit.edu		 |
|	obligatory disclaimer	: My views don't represent anyone but me |
|	obligatory quote	: Nothing takes the taste out of peanut  |
|				  butter quite like unrequited love.	 |
|							-- Charlie Brown |
:________________________________________________________________________:



More information about the Comp.unix.questions mailing list