Visit Our UNIX and Linux User Community

List and Compare Files accross different servers.

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting List and Compare Files accross different servers.
# 1  
Old 11-07-2011
List and Compare Files accross different servers.

Hi all,

This is my situation. First thing is I cannot use rsync to accomplish this. I don't have on my systems and we can't put it on. I run HP-UX 11v3.

I have a list of files generated every day which tells me which files are not in sync with the rest of the servers.
I want to ls -l the files on that list and compare the time stamps and sizes to other servers. And I want to automatize it.

Here is what I have so far:


while read fname; do
   /usr/local/bin/hosts /usr/bin/hostname | while read box
      ssh "${box}" "/usr/bin/ll \"${fname}\""
      echo "${box} $fname"
done < /home/user/bin/dirsyncfiles

Some explanations:

/usr/local/bin/hosts is a file which lists all hosts to be synced.
/usr/bin/hostname is a file which list the hostname of the server you are running the script from (need it so I can compare the files on the server I'm on as well).
/home/user/bin/dirsyncfiles is a file containing the file locations to be checked.
/usr/bin/ll is just a custom compiled version of ls -l.

My problem is that the scripts breaks after it lists the files on the first server it checks it on.

hostb file_location ll_file_info
hostb ~ ~
hostb ~ ~
Also it is not really usable because it doesn't compare the file time stamps and sizes.I know I could probably use diff to compare them visually or a find | xargs somehow. I'm not really good at doing these little scripts. Is there a better way to do this.

I have another script which the good people of this site have helped me with that compares MD5 sums, but that will only tell me that they are different, and not why.

I know rsync is a to-go tool for these things however I can't use it. I need some help to automate this as best I can without manually checking 30 different file locations on 10 different servers. Sometimes even more files.
# 2  
Old 11-07-2011
Seems md5 has been excluded. I remove my comments.

Last edited by rdcwayx; 11-07-2011 at 08:25 PM..

Previous Thread | Next Thread
Test Your Knowledge in Computers #961
Difficulty: Medium
SQL MammyJammer was a computer worm that caused a denial of service on some Internet hosts and dramatically slowed down general Internet traffic in 2003.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to compare the two files and list out differences between the two

Hi, I need to compare the two files and list out difference between the two. Please assist. Best regards, Vishal (2 Replies)
Discussion started by: Vishal_dba
2 Replies

2. Shell Programming and Scripting

Compare two files and print list

Hi Gents, I have 2 files as seen below. File 1: 9 1020 10 1001 11 1001 12 1002 13 1003 14 1004 15 1004 File 2: 9 1000 11 1001 12 1002 13 1003 15 1004 (5 Replies)
Discussion started by: jiam912
5 Replies

3. Shell Programming and Scripting

Compare files in 2 servers

I need to compare same set of files in 2 different servers and generate a list (in STDOUT) which contain all the files that have changed. I don't have permission to create any temp files or folders in either servers. - One option is to use ' if '. But for this I need to move file1 to one server... (1 Reply)
Discussion started by: vskr72
1 Replies

4. Shell Programming and Scripting

Compare the files in 2 different servers for change or modification

I have the following requirement; I need to compare set of files in 2 different servers A and B. Both have same sets of files and directory structure First I need to move the files from Server A to server B Compare the corresponding file in B server and see if it has modified (not... (1 Reply)
Discussion started by: vskr72
1 Replies

5. Shell Programming and Scripting

Compare two directories in different servers

I have a requirement. I need to write a shell script which will compare two directories residing in two different servers (SERVER A and SERVER B) and list out the discrepancies if found any. Script will be running from SERVER A. Please help. (2 Replies)
Discussion started by: freakysk
2 Replies

6. Shell Programming and Scripting

Compare list [ names and size files ]

Hello, I've downloaded a huge amont of files I've got a list of files from a remote server. -rw-r--r-- 1 str661 strem 453465260 Dec 16 15:54 -rw-r--r-- 1 str661 strem 17669468 Dec 16 18:01 -rw-r--r-- 1... (9 Replies)
Discussion started by: Aswex
9 Replies

7. Solaris

directory compare in two different servers

How can we get the directory tree along with the size in two different servers and find the difference between the list..?? Eg, Server1 dirTree1 -size Server 2 dirTree2 -size how can we find the directory tree with its size, and find the difference, where the servers are different... (1 Reply)
Discussion started by: vikram3.r
1 Replies

8. Shell Programming and Scripting

Summation of Columns accross multiple files

I have around 1000 files in a directory (file1.txt, file2.txt, ... file1000.txt), each file is 2 columns, the first colums are same for all of them, second one is different. file1.txt 1 10 2 20 3 30 4 40 5 50 file2.txt 1 100 2 400 3 500 4 600 5 900 what I need is , I want... (3 Replies)
Discussion started by: scriptie
3 Replies

9. Shell Programming and Scripting

Script to compare all the config files in a cluster of servers.

Hello Lads! Climbing the shell scripting learning curve, i am faced with yet another obstacle! Here's the challenge in front of me : 1) I have 15 servers in a cluster,all of them have the same config files by name : /home/apps/xrm/App_B.cfg 2) The developers change the entries in the... (5 Replies)
Discussion started by: rdlover
5 Replies

10. UNIX for Advanced & Expert Users

want to mail a list of files in different servers

Hi All, I am running my script in crontab and it is generating a file everyday. And I have 10 different servers and i am running the same script in every server in crontab which generates a file in every server per day. I want to retrieve those files from each server everyday. I want to... (1 Reply)
Discussion started by: AshishK
1 Replies

Featured Tech Videos