ftp script SUMMARY

2007-12-25 7:12:00

Thank you for all your suggestions. You have all been most helpful.

Here is a summary my venture into finding a method of ftping files

automatically:

[ 1 ]

The use of popen to pipe a script into ftp was suggested by

<veum@atria.GSFC.NASA.GOV>. This may work but there are easier

ways of doing things.

[ 2 ]

The following people suggested that I download the program

BFTP from <venera.isi.edu> for doing background ftp:

<dna@fredholm.math.psu.edu>, <kam@titan.tsd.arlut.utexas.edu>,

Janet L. Carson <jcarson@moniz.bcm.tmc.edu>, <davy@itstd.sri.com>

Paul O'Neill <pvo3366@oce.orst.edu>

I have and from looking at the man pages it looks quite impressive

and powerful. I was able to compile things properly, but I'm having

problems using it. I have send an email to Annette and we are in

the process of determining the source of my problems.

[ 3 ]

The following people send me long scripts that does ftp, file checking,

and a bunch other bells and whistles:

Dikran Kassabian <deke@ee.rochester.edu>, <bchivers@smiley.mitre.org>

These were written for specific purposes and may be modified to suite

one's needs. If anyone is interested, they can email me and I'll send

them a copy of these scripts.

[ 4 ]

The following people send me a simplier version of shell scripts for

redirecting a ftp script into ftp:

<selig@xanth.msfc.nasa.gov>, <dupuy@hudson.cs.columbia.edu>,

<me@scubed.scubed.com>, <cfoley@arsenic.cray.com>, <dlc@monsoon.c3.lanl.gov>,

<harry@neuron1.JPL.NASA.GOV>, <lrj@helios.TN.CORNELL.EDU>,

Don Hooper <hoop@khonshu.colorado.edu>, Mitch..Wright <mitch@hq.unspecified>,

<nick%orange@gargoyle.uchicago.edu>, <gcm!amadeus!dal@uunet.UU.NET>,

"alex;923-4483" <alexl%daemon.cna.tek.com@RELAY.CS.NET>,

King Ables <ables@mcc.com>, <lewis@saint.mitre.org>,

Frank G. Fiamingo <frank@tardis.ircc.ohio-state.edu>,

<Dave_Brent@mtsg.ubc.ca>, <iotek!mike@uunet.UU.NET>

I have tried redirecting before but my problem was 'ftp < script'

alone would not work. ftp would stop after reading the password.

The problem was solved either by using the .netrc file (so that

the login name and password need not be entered), or by using

the -n option of ftp (then the first line in the ftp script

should be 'user <login name> <password>'.

[ 5 ]

John, <kelso@seas.gwu.edu>, was a little more helpful where he

suggested using a while loop to keep ftping until the file wanted

exists. That makes more sense since my problem in the first place

was not being able to sign onto sites because of too many anonymous

ftps and connection was not allowed. Therefore, I wanted to make a

script to start at night and keep trying until I get the file.

With a little more help from John (debugging a syntax error in

my script), here is the final version of my script:

========

#!/bin/sh

#

# Script for auto ftp of files

#

# remove old log file

#

if [ ! -r log ]

then rm log

fi

#

# keep trying till 'file' is uploaded

#

while [ ! -r file ]

do ftp -i -n -v host.domain.country << END_FTP > log

        user anonymous guest

    lcd download

    cd pub

        binary

    get file

        bye

END_FTP

    if [ ! -r file ]

    then sleep 600

        fi

done

========

Notice that I've decided against using .netrc and place the login id

and password in my script. Reason being Sun has always adviced against

using .netrc unless it's absolutely necssary, for security reasons.

It was documented in their Security Features Guide. To have a .netrc

file, you must make its access rw only by owner. Well, I can do that

for my ftp scripts as well. And doing it through a script, I can have

everything in one file.

[ 6 ]

During the time I've been testing these ftp scripts, an 'autoftp'

program was posted in comp.sys.ibmpc. I designed for Simtel20 but

it came with source codes, so I changed a few things and it works

fine. It doesn't use mget and it downloads the file one file

(per session) at a time (so no wildcards, filenames must be specified).

But I think I like it this way because it has to somehow verify each

file has been downloaded. Therefore, if you specify each filename,

it can verify each file, whereas it would be quite messy to have

to figure out what file the wildcard expansion contains, and then

check for each of those file. The way I've been doing it is set up

an ftp session for downloading the file listing of directories I want

to look at first. Then while setting up the script second session,

I read in the listing into my second script and delete the files that

I don't want while correcting the syntax of the files I do want.

I means one more ftp session but it's a safer way to go. But you can

edit the source code to include mget if you want to. I can post this

'autoftp' program here if anyone is interested.

Thank you for all those that who replied.

I will also be posting a summary of my nameserver question shortly.

Thomas.


--
/*-----------------------------------------------------------------*/
/* Thomas Y. K. Wong INTERNET: thomas_wong@civil.ubc.ca **/
/* Graphics Lab twong@civil.ubc.ca * */
/* Civil Engineering BITNET: thomas_wong%civil.ubc.ca@ubcmtsg * */
/* University of B.C. twong%civil.ubc.ca@ubcmtsg * */
/* Vancouver, B.C. UUCP: ...!van-bc!civil.ubc.ca!thomas_wong * */
/* Canada ...!van-bc!civil.ubc.ca!twong * */
/*-----------------------------------------------------------------* */
/* _________ How can you tell I'm a C programmer? * */
/* :--] '|homas [--: (8 <grin> 8) <= note the glasses. **/
/*-----------------------------------------------------------------*/

Comments

Got something to say?

You must be logged in to post a comment.