[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 653
  • Last Modified:

Trying to Use beyond Compare to notes differences in a file on about 380 servers. Can someone help me script this to an output file.

I am trying to compare a file on about 300 servers.  I just need to note the size and date of the file on each server to a particular baseline file on my workstation.  Does anyone know of a way to script this using beyond compare and piping the information (only the size and date of the file and maybe the crc) to an output file?  I'm needed to know if there is any difference's, but not necessary what those differences are.  If the file is different , we are planning a rollout of the baseline file to all servers that do not have the file installed.  This is an extremely urgent issue and any help would be greatly appreciated.  Sorry, but I am not the greatest at scripting so please be as specific as possible.
0
mdnplace
Asked:
mdnplace
2 Solutions
 
fridomCommented:
I suggest using a Digest Hash value for you files. You then just have to check against this value and see whether the files are equal.

So you could use e.g md5sum or write one md5 hash code yourself.
Probably you better go with sha-1.

Of course stating the file and collecting that information might work, but if you have some server installed later and copied the file on it then what does teh date of the file gives you.

Another approach if you just want to be sure that a certain files exist is using rsync from the Master to the Slaves either as in push or pull direction. You could e.g write a file
files_to_copy

/home/bla/fasel
/home/foo/bar

then you run
for all_servers in my_server_list
   rsync -e ssh -avz < files_to_copy  user@remotehost

or the like

Regards
Friedrich

0
 
mdnplaceAuthor Commented:
Thanks for the quick response.  Right now I do not wish to sync any files only note the servers with a different file than my base line.
Would the code you sent work with beyond compare?  I was thinking I would need a script that I could run using beyond compare.  This file should be located in the same path on all servers.  My only variable would be the different server name.

\\%servername%\path\file.ora.

How would I use a simple text file with all my servernames in it and run the size and crc compare using beyond compare on all servers?
I deal more with networks than programming so forgive me if I ask alot a questions.
0
 
fridomCommented:
Sorry I had not seen oder understand the beyond compare question. I was reading you're looking for way mirroring files, which can be done with rsync quite nicely. I suggest you visit
http://www.scootersoftware.com/ubbthreads/ubbthreads.php
and read a view questions there.

And yes you're right you have to write a script in beyond compare scripting language.

I'm sorry having wasted your time.

Regards
Friedrich
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mdnplaceAuthor Commented:
You haven't wasted my time.  When we go to sync these files the above script might come in handy.  Thanks.
0
 
PaulCaswellCommented:
Hi mdnplace,

I've done this kind of thing many times. I work in EPOS and checking software versions on every till across hundreds of stores is a common requirement.

In the end I wrote a tool to help out. I've since released it on shareware. Its a Win32 app. If you'd like to try it let me know.

It doesn't use 'beyond compare' but it can produce SHA1 or CRC32 details along with date,time,file size etc.

Paul
0
 
JesterTooCommented:
Here is a script that uses FC and PING to compare a "base" file with the same filename to a list of other locations.  It only determines if the binary content is the same or different... this implies that file size must be identical but not the timestamp.

Perhaps it will be useful to you.

Regards,
Lynn

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' COMPARE.VBS
'
' This script reads a text file containing share names in the format of
'     server\share\path\
' and examines each of those shares for the presence of a file.  If found
' the file is them compared to a "base" copy to determine if it is different.
'
' Exceptions are echoed to the console (which can be redirected to a file for further analysis).
'
' Executes "FC /b" to do a binary comparison of two files...
'
'
' Invoke this script like this:  cscript compare.vbs >exception.txt
'                            or  cscript compare.vbs >exception.txt > results.txt  
'
' Note:  If some of the servers are "unavailable" this script will run slowly and
'        appear to "hang up".  It's just the network waiting to timeout before
'        moving on.  This problem can be mitigated somewhat by adding a "ping"
'        command just before the FC command to determine if the server is responding
'        first.
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit

Const ForReading = 1

Dim ServersLst     '-- name of file containing list of shares to examine.
Dim FileName       '-- name of file to be compared on all specified shares.
Dim BaseLocn       '-- name of "base" location that will be compared with all others.
Dim ReturnCode
Dim Command
Dim oFSO
Dim oWSH
Dim oFile
Dim oExec
Dim sPath

   '-- Change these next 3 values to match your environment...
   '--
   FileName   = "SomeFile.txt"
   BaseLocn   = "\\phobos\e$\ee\"
   ServersLst = "E:\EE\Servers.lst"

   Set oFSO = CreateObject("Scripting.FileSystemObject")

   If Not oFSO.FileExists(BaseLocn & FileName) Then
      Wscript.Echo "Base file not found."
      Wscript.Quit
   End If

   If Not oFSO.FileExists(ServersLst) Then
      Wscript.Echo "File containing list of servers not found."
      Wscript.Quit
   End If

   Set oFile = oFSO.OpenTextFile(ServersLst, ForReading)
   Set oWSH = CreateObject("Wscript.Shell")

   Do Until oFile.AtEndOfStream
      sPath = Trim(oFile.ReadLine)
      If sPath <> "" Then
         If Left(sPath,1) <> "\" Then
            sPath = "\" & sPath
         End If
         If Left(sPath,2) <> "\\" Then
            sPath = "\" & sPath
         End If
         If Right(sPath,1) <> "\" Then
            sPath = sPath & "\"
         End If
         Call CompareFiles(sPath)
      End If
   Loop

   oFile.Close
   Set oFile = Nothing
   Set oFSO = Nothing
   Set oWSH = Nothing
   Set oExec = Nothing

Sub CompareFiles(sPath)

   If Not Ping(sPath) Then
      Wscript.Echo "Unavail " & sPath
      Exit Sub
   End If

   If Not oFSO.FileExists(sPath & FileName) Then
      Wscript.Echo "Missing " & sPath
      Exit Sub
   End If

   Command = "FC /b " & _
             chr(34) & BaseLocn & FileName & chr(34) & " " & _
             chr(34) & sPath    & FileName & chr(34) & " >nul"

   ' do the comparison...
   ReturnCode = oWSH.Run(Command, 0, True)

   if ReturnCode = 0 Then
'''   Wscript.Echo "Same    " & sPath     '' commented so only exceptions are displayed
   else
      Wscript.Echo "Diff    " & sPath
   end if

End Sub


Function Ping(sComp)
Dim sCommand
Dim sOutput
Dim sServer
Dim n

   sServer = sComp
   If left(sServer,2) = "\\" Then
      sServer = Mid(sServer,3)
   End If

   n = InStr(sServer, "\")
   If n > 0 Then
      sServer = left(sServer,n-1)
   End If

   sCommand = "%comspec% /c for /f %q in ('ping -n 1 -w 500 "
   sCommand = sCommand & sServer
   sCommand = sCommand & " ^| find /i ""reply""') do (echo 1)"
   Set oExec = oWSH.Exec(sCommand)

   sOutput = sOutput & oExec.StdOut.ReadAll

   Ping = Len(sOutput) > 0

End Function
0
 
mdnplaceAuthor Commented:
That looks like it will definately work.  I will try that monday to compare my files.  Thanks for your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now