Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Perl Expert please assist:
This not a hw assignment, this a research work.
I have started it have some code in place, I need your help.Need to compare two diffrent files:
file1.xyz resides in a local server
file2.pqr resides in a remote serverThe script will look for un-match of string next field "name"(file1.xyz first entry of name is "newton" pleas see below example of the data) in both files and only will send out email if there is an un-match and/or duplicates are found.
So here what I have written so far:
# Build an array of the Servers.@Servers = (
'server1',
'server2',
'server3',
'server4',
'server5',
'server6',
);#Location of file2 and then I am copying file2 to diff directory for comparison
#location of file2 in remote server.$file2 = "/os/bbs/file2.pqr"
#copy file2 to this location
$Copy_file2 = "/tmp/Comparelog"
# In a foreach loop copy every single file2 files from all remote serversforearch $RemoteServer(@Servers)
{#Get all file2 files from the Remote Servers
#This command will work directly and will not require passwd. this command scp to every remote servers and will copy all file2 files to "/tmp/Comparelog" directory with servernme
system ("scp -P 1111 $RemoteServer:$Copy_file2. $RemoteServer");
}
NOW I NEED TO FIND OUT OPEN EVERY SINGLE FILE2 TO FROM EACH SERVER from above loo that copies AND THEN COMPARE WITH EACH LOCAL SERVER ("/COMP/CFILE.PPT/file1.xyz)file2.pqr >>>>>>>>>>>>> compare with local server (server 1) file1.xyz
file2.pqr >>>>>>>>>>>>> compare with local server (server 2) file1.xyz
file2.pqr >>>>>>>>>>>>> compare with local server (server 3) file1.xyz
file2.pqr >>>>>>>>>>>>> compare with local server (server 4) file1.xyz
file2.pqr >>>>>>>>>>>>> compare with local server (server 5) file1.xyz
should I also copy all local file1.xyz to "tmp/Comparelog" directory or I can compare on the fly
here ("/COMP/CFILE.PPT/file1.xyz)
The e-mail should output as follow:Listed below are sites that need to be looked at for NOT existing in files on BOTH Local and the Remote servers:
File on Server1 :
(/abc/def/file1.xyz)File on Remote Server: (/os/bbs/file2.pqr)
(Print the above only ONCE! top of the e-mail header)
***********************************UNMATCH FOUND**********************
Local(Server1) Remote(Server2)
None einsterin
Local(Server1) Remote(Server2)
watts None
*************************DUPLICATES FOUND**********************
Local(Server1) Remote(Server2)James None
None cook
lavoyse lavoyse
file1.xyz format: (located in local server)
turning on
name newton
point direct
terminal 2
protocol TCP
port 197
turning on
name darwin
point direct
terminal 2
protocol TCP
port 197turning on
name curie
point direct
terminal 2
protocol TCP
port 197
turning on
name farad
point direct
terminal 2
protocol TCP
port 197
turning on
name watts
point direct
terminal 2
protocol TCP
port 197turning on
name james
point direct
terminal 2
protocol TCP
port 197turning on
name james
point direct
terminal 2
protocol TCP
port 197
turning on
name lavoyse
point direct
terminal 2
protocol TCP
port 197turning on
name lavoyse
point direct
terminal 2
protocol TCP
port 197Following is file2.pqr (Remote server forexample Remote server - remote server 2
turning on
name newton
point direct
terminal 2
protocol TCP
port 197
turning on
name darwin
point direct
terminal 2
protocol TCP
port 197turning on
name curie
point direct
terminal 2
protocol TCP
port 197
turning on
name farad
point direct
terminal 2
protocol TCP
port 197turning on
name einsterin
point direct
terminal 2
protocol TCP
port 197turning on
name cook
point direct
terminal 2
protocol TCP
port 197
turning on
name cook
point direct
terminal 2
protocol TCP
port 197turning on
name lavoyse
point direct
terminal 2
protocol TCP
port 197

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |