PDA

View Full Version : Compare Status of two Text Files


Satyabrata Saha
25-Jun-2011, 07:48 AM
Hi,

I have a requirement to compare two files at a time and report PASS if the content of the two files are same and report as FAIL if the two files have one or more differences.

Bassically, the idea is to have a return value or any sort of information which says that the two files compared are similar or dissimilar.

Thanks in Advance

Craig
25-Jun-2011, 07:51 AM
BC returns the comparison status as the process exit code. The specific values are covered in the help file under "Command line reference". If you don't need a comparison window just use the /qc switch to do a non-interactive comparison.

Satyabrata Saha
25-Jun-2011, 08:11 AM
Hi Craig,

Thanks for yoyr quick response.

i am currently using this script below:
log normal "F:\TestBC\3\Report%date%.txt"
load "F:\TestBC\1" "F:\TestBC\2"
filter "*.txt"
expand all
select all
file-report layout:side-by-side options:line-numbers output-to:"F:\TestBC\3\Report%fn_time%.html" output-options:html-color

The above code do show any window or GUI. It reports the coparison similarities and differences on a html file.
Here how can I get the file comparison status only.

Aaron
27-Jun-2011, 08:28 AM
Hello,

If you are trying to show only the different lines in the report, you need to use:
text-report layout:side-by-side options:display-mismatches,line-numbers output-to:"F:\TestBC\3\Report%fn_time%.html" output-options:html-color

If you use "folder-report" instead of file-report, it will generate a side by side list of file names and indicate their comparison status. You would need to remove options:line-numbers, since that wouldn't apply:
folder-report layout:side-by-side output-to:""F:\TestBC\3\Report%fn_time%.html" output-options:html-color

I would recommend using the GUI to create the report you need first. Once you know the report style in the GUI, it is easier to determine which script you need.

If one of our report styles does not work for you, Craig's suggestion was to create your own script (a batch file) and use bcompare.exe /qc, which returns a DOS level error code, which you can then manually interpret and create a report.

I would recommend using our script and reports if you can; it is a bit easier to setup.