ftp from a file list, how?
Don Libes
libes at cme.nist.gov
Sat Jul 21 02:06:52 AEST 1990
In article <23921 at adm.BRL.MIL> xphyhofu%DDATHD21.BITNET at cunyvm.cuny.edu ( Joachim Holzfuss) writes:
>I have to ftp files automatically from a directory,that grows permanently.
The recent USENIX Proceedings (Anaheim) included a paper on a program
I wrote called "expect" that can solve this type of problem. expect
is a general system for automating interactive programs, not just ftp.
>What I did was:
> ftp> mget file.*
> ftp> mdelete file.*
>with the result, that files ariving between both calls get deleted by mdelete.
>Now there is
> ftp> ls file.* inlist
>which I could use, but I can't do:
> ftp> mget "/bin/cat inlist" (works for ls file.* "more" )
>or something like (using a macdef)
> ftp> $transfer file.* (no globbing possible)
>
>Seems like ftp doesn't like me. Any good ideas?
An expect script could do everything including starting up ftp, but
here is just the interesting portion. I'll assume the script has
already sent the ftp commands to create the file "inlist" as in your
original message. The rest of the script is then:
set inlist [exec cat inlist] ;# read into variable inlist
set len [length $inlist]
for {set i 0} {$i < $len} {set i [expr $i+1]} {
set file [index $inlist $i]
send get $file\r ;# get the file
expect *successful*ftp>*
send delete $file\r ;# delete it on remote system
expect *successful*ftp>*
}
It helps if you know Tcl - the language expect uses - but it looks
very much like a cross of the shell and C, so you can probably discern
how the script works just by looking at it.
expect may be ftp'd as pub/expect.shar.Z from durer.cme.nist.gov. If
you cannot ftp, you may request email copies by mailing to "library@
cme.nist.gov". The contents of the message should be (no subject
line) "send pub/expect.shar.Z". Once you have retrieved the system,
please read the INSTALL file. The paper mentioned above can be ftp'd
as pub/expect.ps.Z.
Don Libes libes at cme.nist.gov ...!uunet!cme-durer!libes
More information about the Comp.unix.wizards
mailing list