LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-07-2011, 10:12 AM   #1
bearitall
LQ Newbie
 
Registered: Jan 2011
Posts: 1

Rep: Reputation: 0
Need to vaidate SCP move


Hey,
I am new to Linux and I am developing my first script. Yay for me that the copy works, however i need to write some logic into it to "validate the files i moved are on both the source and destination, BEFORE i remove the files from the source" Any help would be appreciated

find /source -mtime +3 -type f | grep file.log |xargs -i scp '{}' DestinationServer:/destination location 2>/dev/null
echo $?
 
Old 01-07-2011, 10:20 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
I'd look into rsync which will do a lot of the heavy lifting for you. It's extremely clever at determining which files need to be transferred from the source to the destination.

Last edited by pwc101; 01-07-2011 at 10:24 AM.
 
Old 01-07-2011, 10:37 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,886

Rep: Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258Reputation: 4258
Quote:
Originally Posted by bearitall View Post
Hey,
I am new to Linux and I am developing my first script. Yay for me that the copy works, however i need to write some logic into it to "validate the files i moved are on both the source and destination, BEFORE i remove the files from the source" Any help would be appreciated

find /source -mtime +3 -type f | grep file.log |xargs -i scp '{}' DestinationServer:/destination location 2>/dev/null
echo $?
I'd agree with pwc101's advice, and go with rsync. However, if you want to/have to stick with SSH/SCP, consider doing an md5sum on the file(s) in question. Since you're getting to SCP without a password, I'll assume you have your SSH keys swapped already.

Add a line into your script, to do something like:
Code:
ssh user@remote.host "md5sum <filename>"
into a variable. Then, run the md5sum against the same file locally. They should match..if not, burp out an error/try again/whatever.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I move an LVM as I can move an ISO tkmsr Linux - Server 5 10-05-2010 11:18 AM
cannot using FTP move command to move files adrianmak Linux - Networking 4 04-21-2009 12:01 PM
rtorrent - Move when download completes. Move again after seeding completes. Calab Linux - Software 1 01-29-2009 01:47 AM
scp does not work and gives the following error message: scp: FATAL: Executing ssh1 i akay Linux - Networking 16 09-28-2008 11:41 PM
Help with SCP lfindle Linux - Newbie 14 07-09-2002 02:08 PM


All times are GMT -5. The time now is 04:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration