Comparing directories on different unix servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparing directories on different unix servers
# 1  
Old 10-29-2009
Comparing directories on different unix servers

Is it possible to use the diff command to compare two directories on different Unix (AIX) servers?

We have two regions set up and we want to be able to compare if the scripts directory in both regions contain the same files?

I want to figure out if its possible.. Have been messing around by dumping the listing of each dir into separate files and comparing them with diff.. But that doesn't work the way i need it to..

Is there any other command out there that could work?

Thanks,
Jaz

EDIT**

Can something like this work?? I've tried it from the command line but it gives the following error.

ksh: syntax error: `(' unexpected


Code:
diff <(ssh server_name 'cd directory_to_compare; find . -type f -exec {} \;| sort -k 2') <(ssh servername2 'cd directory_to_compare; find . -type f -exec {} \;| sort -k 2') >> diff_report.txt


Last edited by Jazmania; 10-29-2009 at 10:56 PM..
# 2  
Old 10-30-2009
don't understand your command, there is no command follow by -exec, if the missed command is ls, then you needn't -exec, use -print (or not, -print is default for find) will export the file list.

Because there is no command for -exec, I don't understand what you sort for.

Code:
diff <(ssh server_name 'find directory_to_compare -type f | sort') <(ssh server_name 'find directory_to_compare -type f | sort')

# 3  
Old 10-30-2009
Ok, maybe I don't need the sort.. Just tried

Code:
diff <(ssh paehowup2303 'find /home/x136873 -type f') <(ssh njros1up2303 'find /home/x136873 -type f')

still getting ksh: syntax error: `(' unexpected


I'm running this straight from command line at the minute.. do i need the ' in the command?
# 4  
Old 10-30-2009
In which shell do you run the command?

Try if you have bash.

Code:
bash diff <(ssh paehowup2303 find /home/x136873 -type f) <(ssh njros1up2303 find /home/x136873 -type f)

# 5  
Old 10-30-2009
Korn shell..

---------- Post updated at 09:37 PM ---------- Previous update was at 04:45 AM ----------

Would it be possible to use the "rsync --dry-run" option to find differences in directories on separate servers.. Only just come across the command and not sure how it works.. The man pages are pretty long.. When comparing the directories can the command work over ssh? I'm can't get my head around how the command works...

Last edited by Jazmania; 10-30-2009 at 06:44 PM..
# 6  
Old 10-31-2009
In Korn shell I would expect something more like this: -

Code:
diff <$(ssh paehowup2303 'find /home/x136873 -type f')  <$(ssh njros1up2303 'find /home/x136873 -type f')

The $ gets rid of the unexpected ( error but I think it still wont work as the diff is expecting file names
# 7  
Old 10-31-2009
No, the syntax is correct with the <(..) constructs. Jazzmania, my guess would be that you are running ksh88 on the system you are firing the command from. What happens if you run this:
Code:
(echo ${.sh.version}) 2>&- || echo ksh88

Perhaps /bin/ksh93 is present on your system too. If so try start up that shell and try running the command from there.

Quote:
Originally Posted by Jazmania
.. do i need the ' in the command?
No, you can leave them out.

Last edited by Scrutinizer; 10-31-2009 at 08:28 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing two directories with diff

Hi all, I have 2 directories on two different servers. I am trying to find out what is missing from directory X and what is missing from directory Y. they should both have the same exact files in them. I understand some files may be missing from both directories on each server. I am not sure... (8 Replies)
Discussion started by: jeffs42885
8 Replies

2. UNIX for Beginners Questions & Answers

Comparing time differences between 2 Solaris servers

Good day to all. I'm relatively new in using the Sun Solaris OS. I would like to request your expertise in helping to solve a problem that I have at work. Not sure if this has been asked before but I have tried searching through the internet to no avail. Basically I have 2 sun solaris... (8 Replies)
Discussion started by: Fossil_84
8 Replies

3. Shell Programming and Scripting

Comparing 2 UNIX directories

Hello, I'd want to compare the content of 2 directories in unix. I use the diff command like this: diff /home/user/AAAAA /home/user/BBBBB It works fine, but when a same file is in both directories and they are diferents, I'd want to see only that it is diferent and not all... (4 Replies)
Discussion started by: nolo41
4 Replies

4. Shell Programming and Scripting

Comparing files names in directory over two servers

Hi folks I need to write a shell script to check whether source and the destination has the same files. The source and destination are over two servers and connecting through ssh. It should even compare the date i.e, the complete file name, date stamp and size should match. Should list out all the... (3 Replies)
Discussion started by: Olivia
3 Replies

5. Shell Programming and Scripting

Comparing Virtual servers

Hi I need a script to run on a Solaris server to confirm if it is a physical server or a Virtual server please help Mandaken (0 Replies)
Discussion started by: madmacher
0 Replies

6. Homework & Coursework Questions

comparing 2 directories

i have been asked to write a bash shell script comparing two directories and sed or awk should not be used in this assignment. compdir will compare filenames in two directories, and list information about filenames that are in one directory but not the other. The information listed will be a long... (1 Reply)
Discussion started by: soccerball
1 Replies

7. UNIX for Dummies Questions & Answers

comparing the content of two directories

Hello I want to compare the content of two directories recursively to check if the two directories have the same files. How can I do that? (2 Replies)
Discussion started by: xyzt
2 Replies

8. UNIX for Dummies Questions & Answers

Comparing directories via ftp

Hello! I am trying to compare a list of files in 2 directories - one on our unix server (I'll call it 'ours') and one on a site we ftp to (I'll call it 'ftp'). I need to make sure that after we ftp, the names that we put out there match the names we have on our side. I was thinking to create a... (1 Reply)
Discussion started by: tekster757
1 Replies

9. Solaris

comparing 2 Solaris servers

hello has anyone built a script that compares 2 Solaris servers? CPU, memory, swap, memory variables in /etc/system, Solaris version Could you please advise on how to make such a comparaison? thanks (9 Replies)
Discussion started by: melanie_pfefer
9 Replies

10. Shell Programming and Scripting

moving directories to new directories on multiple servers

Hi - I am new to unix scripts...I need to move several directories on multiple servers to new directories. (0 Replies)
Discussion started by: mackdaddy07
0 Replies
Login or Register to Ask a Question