Announcement

Collapse
No announcement yet.

Compare multiple files on different domain URLs and open BC session for differences

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compare multiple files on different domain URLs and open BC session for differences

    I am new to BC and trying to understand scripting and command line options.

    Here is what i would like to achieve:
    1. I have 3 different environments setup as subdomains sys.ex.com / pat.ex.com and ex.com (for production)
    2. I need to move files between these domains very often about 50-60 files as part of deployment
    3. The files are only available via URLs post the deployment.
    4. In order to say that the deployment was a success, we need to compare all the files between two environments. Let's say i move 50 files from sys to pat environment. I should be able to run a comparison between sys.ex.com and pat.ex.com for all the 50 URLs. I am only interested in the files where there are differences. If they are same, deployment was a success and i don't wish to see the comparison
    5. Later when i move the files from pat.ex.com to ex.com, i need to compare those 50 files again just this time it has to be a pat vs production comparison
    6. The URL for files are something like:
    a) sys.ex.com/path1/file1.txt
    b) sys.ex.com/path2/file2.txt
    c) sys.ex.com/path1/path3/file3.txt
    7. I am looking to pass an input file with the path to the files specified in it and then the two domains i want to compare them on, like so
    Compare sys.ex.com pat.ex.com URLPathFile - for SYS/PAT comparison
    Compare pat.ex.com ex.com URLPathFile - same URLPathFile is used this time for comparing PAT/Production
    8. The URLPathFile varies and i do this comparison every 15 days or so

    Any ideas to make my life easier are appreciated.

  • #2
    Beyond Compare can't read an input file with a list of URLs to compare.

    The best way to compare the files is to access them by FTP or SFTP in Beyond Compare's Folder Compare. Then you can run a Folder Compare of sys.ex.com to pat.ex.com and list different files. Repeat for pat.exe.com to ex.com.

    Example script to compare two folders on an FTP server and list the names of files with content differences:

    Code:
    load ftp://user:password@server1/ ftp://user:password@server2/
    expand all
    folder-report layout:side-by-side options:display-mismatches output-to:report.txt
    To run the script, use the command line:
    "c:\program files\beyond compare 4\bcompare.exe" @c:\script.txt

    The @ character makes Beyond Compare run a file as a script instead of compare it interactively.
    Last edited by Chris; 30-May-2018, 05:46 PM.
    Chris K Scooter Software

    Comment


    • #3
      If you just want to load two URLs in the Text Compare, you can either paste them into the left or right path edits and hit Enter or pass them as command line arguments.

      Example:
      bcompare.exe http://www.scootersoftware.com/ http://www.scootersoftware.com/download.php
      Chris K Scooter Software

      Comment


      • #4
        Thanks for a quick reply Chris!
        I use BC UI when the file count is under 10 (20 URLs total; considering two domains). But it becomes tedious as the count increases.
        I have already tried using Session to save them beforehand and just run it post the deployment. But that too is labor intensive and I need to navigate to each tab to see the results even when there aren't any differences.

        Comment


        • #5
          Hello,

          The file comparison (pairs) can support HTTP, but if you need to compare folders (for many files), I would recommend the FTP/SFTP access Chris mentions above.
          Aaron P Scooter Software

          Comment


          • #6
            Unfortunately, FTP access isn't possible. The deployed files are stored in a database and only available over http/https URLs post the deployment.

            Comment


            • #7
              Sorry, if FTP access isn't possible, there isn't a good method to automate the comparison entirely in BC.
              Chris K Scooter Software

              Comment


              • #8
                So I found a solution that seems to work:
                1. I created a batch file to read through the CSV file that contains relative paths
                2. input csv file and domains are specified in the batch script itself. These can be parameterized and I hae that version working too, but prefer them within the script.
                3. I build the two file paths and invoke BC for the comparison in quiet mode and invoke it again if there are differences.

                The issue i encountered was that irrespective of the BC file i used (BCompare.exe, BComp.exe, BComp.com) my script halted at the first set that had differences. Only when the BC window was closed did the script move on. This issue was resolved by ensuring BC was running before the script was processed. Hence, BC is being invoked at line #6 in the script.

                Batch script:
                ::Reads an input CSV file with relative paths and compares them on domainA and domainB
                @Echo Off
                SETLOCAL EnableDelayedExpansion

                ::Ensure that Beyond Compare instance is running
                BComp.exe

                set InputFile=c:\bc\url.csv

                SET domainA=http://sys.ex.com
                SET domainB=https://pat.ex.com

                for /f "tokens=*" %%A in ('type "%InputFile%"') do (
                SET file1=%domainA%%%A
                SET file2=%domainB%%%A

                BComp.exe /qc !file1! !file2!
                echo !file1!,!file2!,!errorlevel!>>pathOut.txt

                if !errorlevel! NEQ 0 (
                if !errorlevel! NEQ 1 (
                if !errorlevel! NEQ 2 (
                BCompare.exe !file1! !file2!
                )
                )
                )
                )
                Sample CSV:
                /en/abc/address-en.json
                /en/def/coupon-en.json

                Comment


                • #9
                  If you add start to the line that launches BC interactively, that will avoid the need to launch an empty BC session before the comparison loop.

                  Code:
                  start BCompare.exe !file1! !file2!
                  Chris K Scooter Software

                  Comment

                  Working...
                  X