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

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

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.

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

Ok, maybe I don't need the sort.. Just tried

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?

In which shell do you run the command?

Try if you have bash.

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

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...

In Korn shell I would expect something more like this: -

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

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:

(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.

No, you can leave them out.

Ah I get it, sorry I missed you were trying to diff the contents of the directories.

I have not seen the <(..) syntax before, is this peculiar to 93? I use 88 at work so would like to know if this works on that version.

It is called process substitution. I took a look at the man pages. Apparently it is a feature of ksh88 too. However, the man pages say:

So might the reason that it is not working on those AIX systems be that /dev/fd is missing?

Thanks

That may be why I haven't seen it. The code I work on has to run on Solaris and AIX.

I will try it anyway

Cheers

Yeah, got a "No such file or directory" error... Least its a little further..

Ran the

(echo ${.sh.version}) 2>&- || echo ksh88

and it returned ksh88

Also just tried

diff folderA <$(ssh user@server_name /home/x136873/folderA)

Get the error "diff: two filename arguments required"

Also trying the rsync --dry-run command too..

rsync -avvc --dry-run -e ssh * user@server_name:/home/folderA/

Almost have this working... having a problem getting the ssh key to work this way tho.. Also getting the message "unexpected EOF in read_timeout" Think this error is more to do with ssh tho..

Not sure where to go from here.. I mean am I tackling the issue from the wrong direction.. Is there some other way of comparing directories that reside on different unix servers another way?