Operating System - HP-UX
1824976 Members
3647 Online
109678 Solutions
New Discussion юеВ

Re: remote diffs (running diff on remote directories)

 
David Gartner
Occasional Contributor

remote diffs (running diff on remote directories)

Hi

I was woundering if there was a way to run diff against a local and remote directory. I thought about nfs mounting the remote file system but the network link speed we have is less than that supported by HP-UX (according to the documentation). Ideally I thought maybe there was a command similar to rcp where you could specify the hostname:/path

e.g. diff remote_host:/path/to/check local_host:/path/to/check

Is there such a beast?

Regards
David
hmmmmm.........
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: remote diffs (running diff on remote directories)

Hi David,

No diff w/o NFS will not do this but if all you want to know is are the two files different
there is a way - use cksum or sum.

e.g.

REMOTE_HOST=elvis
FILES="/tmp/myfile1 /tmp/myfile2"
for X in ${FILES}
do
LOCAL=`cksum ${X}`
REM=`remsh ${REMOTE_HOST} cksum ${X}`
if [ "${LOCAL}" != "${REM}" ]
then
echo "File ${X} different"
fi
done

BTW - I have run NFS over slow links.

Regards, Clay

If it ain't broke, I can fix that.
David Gartner
Occasional Contributor

Re: remote diffs (running diff on remote directories)

Thanks for the prompt answer Clay.

In my case your approach is certainly do-able but there are a large number of files and directories under a particular root dir that I want to compare. That's where the recursive feature of "diff" would come in handy 8-)

Any other suggestions?

David
hmmmmm.........
Ovidiu D. Raita
Valued Contributor

Re: remote diffs (running diff on remote directories)

Whay don't you just expand Clay's idea and built the recursion yourself?

$local_dir=LOCALDIR
$remote_dir=REMOTEDIR
$remote_sys=REMOTESYSTEM

find $local_dir | xargs -i cksum {} > local.out
remsh $remote_sys "find $remote_dir | xargs -i cksum {}" > remote.out
diff local.out remote.out

Good luck,
Ovidiu
Simple solutions to complex problems