Newsgroups: comp.protocols.tcp-ip
Path: utzoo!sq!news
From: news@sq.sq.com
Subject: Re: One-shot ftp client
Message-ID: <1990Feb26.200045.24761@sq.sq.com>
Reply-To: ian@SQ.Com (ian)
References: <792@winnie.fit.edu> <1990Feb18.000713.28831@axion.bt.co.uk>
Date: Mon, 26 Feb 90 20:00:45 GMT


In article <792@winnie.fit.edu>, rcs89301@zach.fit.edu ( Thomas E.
Currey) writes:
> 
> usage :  shftp address loginname password [file1 file2 file3 file4
file5 file6]
> 
> -----------------------CUT HERE Beware no comments read manual--------------
> #! /bin/sh
> cat "machine $1 login $2 password $3" >> $HOME/.netrc
> chmod 600 $HOME/.netrc
> echo "binary
> get $4 
> get $5 
> get $6 
> get $7 
> get $8 
> get $9 
> quit" > $HOME/ftp.tmp
> ftp $1 < $HOME/ftp.tmp > /dev/null       
> rm $HOME/ftp.tmp
> --------------------------------------------------------------------------

Here is a version that has a greater chance of working (it echoes the
arguments into ~/.netrc, instead of trying to cat a non-existant file onto
it :-( ), and that makes the computer do the gruntwork like making the temp
file and remembering what args go where.

#! /bin/sh
# yet another batch ftp client
# usage: shftp address loginname password file1 [file2 file3 file4 file5 file6]

machine=$1
login=$2
passwd=$3
shift; shift; shift;
echo "machine $machine login $login password $passwd" >> $HOME/.netrc
chmod 600 $HOME/.netrc

ftp $machine <<!
binary
get $1
get $2
get $3
get $4
get $5
get $6
quit
!
sort -u -o $HOME/.netrc $HOME/.netrc & # now filter out dups, in background


Ian Darwin
ian@sq.com

