I want to develop one unix script that will first match the multiple files on one server say A with multiple files on another server say B and copy those to server A. After that need to compare the contents of these 2 set of multiple files on different location on same server and generate the mismatch report.
Any help one this would be more helpful. Thanks.
Have you considered using rsync? It can probably do what you want with a lot less fuss.
Kind regards,
Robin
No, this is just for copying files from another server to local server. Secondly, it will ask for password everytime. I dont want this.
rbatte1
October 17, 2017, 12:15pm
4
So that is that not a good job for rsync? How do you propose to authenticate with the remote server anyway?
I might be missing the point, but if you copy the files from ServerB to ServerA then they should be the same. What is the report to highlight?
Please can you clarify your requirement a little more.
Thanks, in advance,
Robin
This is exactly what rsync
was made for. You have gotten very good advice from my colleague rbatte1!
From the man page of rsync
(which, i suggest, you should read instead of disregarding it):
Some modules on the remote daemon may require authentication. If so,
you will receive a password prompt when you connect. You can avoid the
password prompt by setting the environment variable RSYNC_PASSWORD to
the password you want to use or using the --password-file option. This
may be useful when scripting rsync.
And, a few lines later:
You may also establish a daemon connection using a program as a proxy
by setting the environment variable RSYNC_CONNECT_PROG to the commands
you wish to run in place of making a direct socket connection. The
string may contain the escape "%H" to represent the hostname specified
in the rsync command (so use "%%" if you need a single "%" in your
string). For example:
export RSYNC_CONNECT_PROG='ssh proxyhost nc %H 873'
rsync -av targethost1::module/src/ /dest/
rsync -av rsync:://targethost2/module/src/ /dest/
The command specified above uses ssh to run nc (netcat) on a proxyhost,
which forwards all data to port 873 (the rsync daemon) on the targeth-
ost (%H).
Notice that ssh
may use exchanged keys to allow passwordless connections. Find details about this in the man page of ssh
.
I hope this helps.
bakunin