[comp.unix.questions] FTP Command input from file?

psm@manta.NOSC.MIL (Scot Mcintosh) (01/09/90)

I want FTP to execute a canned set of commands from a
local file as though I had typed them from the console.
None of the shell tricks seem to work with FTP.  Can
anyone suggest a way to do this?


-- 
----
Scot McIntosh
Internet: psm@helios.nosc.mil
UUCP:     {ihnp4,akgua,decvax,decwest,ucbvax}!sdscvax!nosc!psm

emv@math.lsa.umich.edu (Edward Vielmetti) (01/09/90)

This works with Ultrix 3.1 (UWS 2.1) and SunOS 4.0.3
FTP.  It may work for you.

The keys are the ftp options "-i" to inhibit prompting during 
multifile transfers, and "-n" to disable automatic login.

ftp -in <yer-file-here

yer-file-here contents:

open ftp.host.org
user anonymous guest
cd pub
get README README-host.org

--Ed

scott@csusac.csus.edu (L. Scott Emmons) (01/09/90)

In article <991@manta.NOSC.MIL> psm@manta.nosc.mil.UUCP (Scot Mcintosh) writes:
>I want FTP to execute a canned set of commands from a
>local file as though I had typed them from the console.

You need to do two things to make this work.

1> set up a .netrc file in your home directory.  The format is (At least on our
   flavor of unix, so you may wish to check documentation; but I don't expect
   it to be different...):

machine <machine_name> login <login_name> password <password>

   for example, my .netrc entry for simtel20 is:

machine simtel20.arpa login anonymous password guest

2> once the .netrc file is set up, you just redirect stdin into ftp from the
   file of commands, which MUST END WITH THE 'bye' COMMAND.

   for example if I wish to get the file "blather.tar-Z" from the
   "pd2:<unix-c.somedir>" directory, and let's say, deposit it in my local
   "ftp/unix/source" directory, my file would read:

lcd ftp/unix/source
cd pd2:<unix-c.somedir>
tenex
get blather.tar-Z
bye

   and from the prompt:

o% ftp simtel20.arpa <myfile

   That's all there is to it!  Enjoy!!!

-- 
			L. Scott Emmons
			---------------
		...[!ucbvax]!ucdavis!csusac!scott
		ucdavis!csusac!scott@ucbvax.berkeley.edu