DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Shell Scripting (http://www.daniweb.com/forums/forum113.html)
-   -   ftp and compare script (http://www.daniweb.com/forums/thread46754.html)

mcrosby May 31st, 2006 9:14 am
ftp and compare script
 
Hello,
I am new to shell scripting but I am attempting to create a script that connects to an ftp and downloads a folder of files. It then compares the downloaded folder on the local machine to another local folder. I am not sure how to work the compare function at the moment i was looking into diff's. I would also like to record the differences to a file i am also not sure how to do this. Here is what i have so far i was hoping someone could help or point me in the right direction.

Quote:

# !/bin/bash
ftp -n -i <<EOF
open ftp.coe.neu.edu
user user pass
bin
cd www/backup
lcd ~/Desktop/backup
mget *.*
lcd ~/Desktop/
disconnect

diff backup bin
EOF

mcrosby May 31st, 2006 9:36 am
Re: ftp and compare script
 
Ok i seem to have the diff script working on its own and it records the differences to a file. How would i go about combining my ftp script and my diff script because if i end the ftp script it closes out the script entirely.

kamitsin May 31st, 2006 1:17 pm
Re: ftp and compare script
 
# !/bin/bash
ftp -n -i <<EOF
open ftp.coe.neu.edu
user user pass
bin
cd www/backup
lcd ~/Desktop/backup
mget *.*
lcd ~/Desktop/
disconnect
EOF

diff backup bin

I hope this is what you wanted ???

EOF Checks for end-of-file condition on open file hence close the file and then use diff.

mcrosby May 31st, 2006 1:54 pm
Re: ftp and compare script
 
yes i had actually already figured that out but thank you for your help

jim mcnamara Jun 1st, 2006 11:01 am
Re: ftp and compare script
 
cksum is a fast way to see if two files are the same.

However, ftp-ing folders of files over just to compare files is a waste of bandwidth and time. What exactly are you trying to do - not how, but what do you need to acheive?

mcrosby Jun 2nd, 2006 2:25 pm
Re: ftp and compare script
 
im not actually sure I was asked to do it at work and they are using it to test bandwith i believe


All times are GMT -4. The time now is 1:13 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC