*BSD News Article 55044


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!goanna.cs.rmit.EDU.AU!munnari.OZ.AU!news.hawaii.edu!ames!agate!howland.reston.ans.net!news.sprintlink.net!news1.cris.com!news
From: Mark Hunnibell <hunnibel@cris.com>
Newsgroups: comp.unix.bsd.bsdi.misc,comp.unix.admin,comp.unix.misc,comp.unix.programmer
Subject: Re: Batching FTP File Transfer
Date: 11 Nov 1995 00:21:05 GMT
Organization: Concentric Internet Services
Lines: 54
Message-ID: <480q9h$ojo@spectator.cris.com>
References: <47vrge$65n@news.easyinternet.ca>
NNTP-Posting-Host: crc3-fddi.cris.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.1 (Windows; U; 16bit)
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.bsdi.misc:1492 comp.unix.admin:35091 comp.unix.misc:19521 comp.unix.programmer:30860

Tom Hill <TomHill@EasyInternet.ca> wrote:
>I would like to be able to write a shell script that would perform FTP 
>file transfers on batches of files, from a BSDI server to a Mac running 
>an FTPD host.
>Is it possible to do batched file transfers with the unix FTP client? Can 
>these be automated the the FTP macdef feature?
>I would appreciate hearing from anyone who has done this.

I have a script that runs by crontab entry to get a series of files via 
FTP. You have to be a little careful with what happens next, because the 
FTP connection may fail.  Nonetheless, here's how to do what you want.  

Assuming that your userid on the remote host (xxx.yyy.zzz) is userx and 
the password for the account is yuser, you can create a file with this 
kind of thing:

open xxx.yyy.zzz
user userx yuser
cd /pub/applications
get filename.1
get filename.2
quit

Save the file as "ftp.script." Then, when you are ready to run this 
beastie, do so with this kind of command:

ftp -in < ftp.script > ftp.output

If you are just getting files, then you probably do not need to redirect 
the output to "ftp.output", but if one of the commands is to get a 
directory listing, then you will probably want it stored in a file.

The application that I use this for is rather complex and requires two 
actual FTP sessions, one to get the directory listings and then the 
program analyzes them for new files and creates a custom script to start 
another FTP session and fetch just the new files.

I hope that helps.

Mark Hunnibell
markh@connix.com

ps... if you hear of a better way, please let me know, I might be 
interested in making some changes.