1833738 Members
2498 Online
110063 Solutions
New Discussion

ftp script

 
Srini Motheram
New Member

ftp script

Hi,
I am trying to pass multiple file names to "newer" commnad within ftp script. I can write listing of remote dir. using "nlist" command to local file ...

ftp -i -n -v << End_of_ftp
user ....
cd ...
nlist . filelist
newer "| `cat filelist`"
bye
End_of_ftp

this doesn't work - thanks in advance
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor

Re: ftp script

Hi:

See if this "two-step" script gives you what you want:

#!/usr/bin/sh
#
ftp -i -v -n << EOF
open remotehost
user uuu ppp
cd /tmp/mydir
nlist . /tmp/mylist
bye
EOF
#
while read X
do
ftp -i -v -n << EOF
open remotehost
user uuu ppp
cd /tmp/mydir
newer $X
bye
EOF
done < /tmp/mylist
#
#.end

This should work OK for UNIX-to-UNIX, but will not work if the remotehost is an NT platform. See this thread:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x197d37f45ef7d4118fef0090279cd0f9,00.html

...JRF...
Shannon Petry
Honored Contributor

Re: ftp script

I think you have to look at the logic of what is occurring in your script.
While
D=`ls`
works within a script what happens if you did the same command at the ftp prompt? You would get an error.

JRF is correct that this is a two step process. NOTE his script example will make a new FTP connection for each file in the list.

If your stuck, try debugging via command line imitation of your script. You will be able to find errors very quickly this way!

Regards,
Shannon
Microsoft. When do you want a virus today?