• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

need script to compare directories in two different servers

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

directory structure is different in both the servers
say

dir structure in Server A - /home/dir/dir2
dir structure in Server B - /office/folder/subfolder/subsubfolder

Script will be working in SERVER A.


Please help.

Server A is Solaris OS.
 
Saloon Keeper
Posts: 24305
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The hardest part is getting local file access to both directory trees. If you have NFS on the Solaris machine, you can export the Solaris share to the Linux machine and run the compare on the Linux machine (or vice versa, if you prefer).

To compare directories in general, I do this:



The "q" option limits the output to just the names of the files instead of details and the "-x .svn" is because I don't want it comparing my Subversion work directories, since they're not important here.
 
Chandrasekaran SanthanaKrishnan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim.

I tried that diff for local directories.

Problem is dir B is in remote host.

I do not know if i can do NFS. If so how to do that?

is there any other way without NFS?
 
Ranch Hand
Posts: 41
Android Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Tim in that getting the network bit right is the key.

There are multiple options here.
1. ftp - you might be able to install ftp service with user permissions.
a. set up ftp on one machine and get the recursive directory listing from another machine using sftp.
2. If you have admin rights, check out NFS way
You need to install nfs server, edit /etc/exports file and start the server.
Then mount the remote folder in A to to a local folder in machine B and compare.
3. if you have access to the web interface of this machine and if it is possible to expose the folder structure via the web interface you could you wget
4. setup rsync between remote and local server.

Any of these will work depending on the permission levels you have on these machines.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic