loftx
July 23rd, 2006, 09:55 PM
Hi all, I'm trying to write a script which logs into my FTP server, gets the list of files in a directory, compares it with a directory on my pc and then downloads any files on the ftp server which arn't on my PC.
I think this can probably be achived with pipes or somesuch thing but can't quite get it to work - here's what I've got so far.
ftp ftp.myserver.com <<** > tempfile
binary
cd logs/W3SVC2867
ls *.cab
bye
**
for FName in $(cat tempfile); do
if [ -f localdirhere/$FName .cab ];
then
X=0 # not sure how to program a not!
else
# copy the file over here
fi
done
rm tempfile
for some reason the for itterates the individual words in tempfile rather than the the lines which messes things up - can anyone help, or suggest an easier way to do what I want,
Thanks,
Tom
I think this can probably be achived with pipes or somesuch thing but can't quite get it to work - here's what I've got so far.
ftp ftp.myserver.com <<** > tempfile
binary
cd logs/W3SVC2867
ls *.cab
bye
**
for FName in $(cat tempfile); do
if [ -f localdirhere/$FName .cab ];
then
X=0 # not sure how to program a not!
else
# copy the file over here
fi
done
rm tempfile
for some reason the for itterates the individual words in tempfile rather than the the lines which messes things up - can anyone help, or suggest an easier way to do what I want,
Thanks,
Tom