User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 391,901 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,596 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 3215 | Replies: 5
Reply
Join Date: May 2006
Posts: 6
Reputation: mcrosby is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mcrosby mcrosby is offline Offline
Newbie Poster

ftp and compare script

  #1  
May 31st, 2006
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.

# !/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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Posts: 6
Reputation: mcrosby is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mcrosby mcrosby is offline Offline
Newbie Poster

Re: ftp and compare script

  #2  
May 31st, 2006
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.
Reply With Quote  
Join Date: Apr 2006
Location: India
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: ftp and compare script

  #3  
May 31st, 2006
# !/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.
Reply With Quote  
Join Date: May 2006
Posts: 6
Reputation: mcrosby is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mcrosby mcrosby is offline Offline
Newbie Poster

Re: ftp and compare script

  #4  
May 31st, 2006
yes i had actually already figured that out but thank you for your help
Reply With Quote  
Join Date: May 2004
Posts: 177
Reputation: jim mcnamara is on a distinguished road 
Rep Power: 5
Solved Threads: 9
jim mcnamara jim mcnamara is offline Offline
Junior Poster

Re: ftp and compare script

  #5  
Jun 1st, 2006
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?
Reply With Quote  
Join Date: May 2006
Posts: 6
Reputation: mcrosby is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mcrosby mcrosby is offline Offline
Newbie Poster

Re: ftp and compare script

  #6  
Jun 2nd, 2006
im not actually sure I was asked to do it at work and they are using it to test bandwith i believe
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Shell Scripting Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 7:31 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC