LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-09-2009, 05:37 PM   #1
abhijeetdutta
Member
 
Registered: Aug 2009
Posts: 139

Rep: Reputation: 16
file comparing


hi,

how to compare should be done between the files in the directory and the files on the server on different location if the file mismatch then it sent alert through bash script.

Thanks
 
Old 09-09-2009, 08:59 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,250

Rep: Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432
Quote:
Originally Posted by abhijeetdutta View Post
hi,

how to compare should be done between the files in the directory and the files on the server on different location if the file mismatch then it sent alert through bash script.

Thanks
Please write clearly, your question is very hard to follow. I *THINK* you're asking "How can I compare files on my local server, to the same files on a remote server, and send an alert if they're different"...is that right?

You can do an "ls -l" on a file locally, which will return the size/date, etc. On the remote, you can do it via ssh, like "ssh <user>@<address> 'ls -l <filename>'", then compare the two.

And if you want to do this through Bash, I will AGAIN suggest you look at any one of the thousands of bash tutorials that are available through Google.
 
Old 09-10-2009, 06:29 PM   #3
abhijeetdutta
Member
 
Registered: Aug 2009
Posts: 139

Original Poster
Rep: Reputation: 16
if you let me know those thousand of tutorial address it will helpful for me tb1....
 
Old 09-10-2009, 07:00 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You can also use the DRY RUN capability of rsync. In DRY RUN mode rsync will show a list of the files that are going to be syncronized (files mismatch) without actually performing any action (files stay out of sync). Here is an example:
Code:
rsync -av --dry-run -e ssh /path/to/source/dir/ user@host:/path/to/destination/dir/
If the files between the two server are exactly the same, you will get an empty list like this:
Code:
$ rsync -av --dry-run -e ssh /path/to/source/dir/ user@host:/path/to/destination/dir/
sending incremental file list

sent 180 bytes  received 15 bytes  390.00 bytes/sec
total size is 151  speedup is 0.77 (DRY RUN)
otherwise you will get a list of the files rsync would have copied to the remote server if not run in DRY mode:
Code:
$ rsync -av --dry-run -e ssh /path/to/source/dir/ user@host:/path/to/destination/dir/
sending incremental file list
./
file1
dir1/
dir1/file2
dir2/
dir2/file3

sent 207 bytes  received 42 bytes  498.00 bytes/sec
total size is 151  speedup is 0.61 (DRY RUN)
In this file list, paths are relative to the source dir. The example above translates to:
/path/to/source/dir/
/path/to/source/dir/file1
/path/to/source/dir/dir1/
/path/to/source/dir/dir1/file2
/path/to/source/dir/dir2/
/path/to/source/dir/dir2/file3
 
Old 09-10-2009, 07:23 PM   #5
abhijeetdutta
Member
 
Registered: Aug 2009
Posts: 139

Original Poster
Rep: Reputation: 16
actually i have wrote a script to download files from ftp...ater downloading it will verify that is any file missed during download on weekly basis...
 
Old 09-10-2009, 10:51 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,250

Rep: Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432
Quote:
Originally Posted by abhijeetdutta View Post
if you let me know those thousand of tutorial address it will helpful for me tb1....
http://www.google.com

Put in "bash script tutorial" Press "ENTER"
 
  


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
bash file comparing question. angeloban Programming 8 06-10-2009 01:51 PM
Question about comparing one file to another in Perl HyperTrey Programming 4 11-20-2008 06:26 PM
file comparing and printing viveksnv Programming 11 02-28-2008 04:55 AM
comparing file xlordt Programming 5 11-19-2007 04:32 AM
comparing music file pantera Programming 2 07-01-2004 03:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:46 PM.

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