Sometimes we need to compare two files quickly. What if your "test" Web site works perfectly, but the production site won't start? You should compare the two Apache configurations to find the glitch.
Fortunately, comparing files is simple with the UNIX command diff, available on iSeries through Portable Application Solutions Environment (PASE), a no-charge option in OS/400 releases since V5R2.
(Why use PASE instead of Qshell? Although PASE and Qshell both provide a UNIX-like command environment and share many commands and utilities, the diff command is specific to PASE. It's easier to run diffin PASE than in Qshell.)
Here's the command syntax for diff:
diff -b FirstFileName SecondFileName
The –b means our comparison will ignore much of the white space it finds. The arguments FirstFileName and SecondFileName represent the two files to compare.
Let's say our test Web server instance is called WEBTST. Our production server is called WEBPRD. WEBPRD has a problem. Let's compare the two servers.
Launch PASE's command line:
Compare our two configuration files using diff:
diff -b /www/webtst/conf/httpd.conf /www/webprd/conf/httpd.conf
The command produces the following (seemingly cryptic) output:
< Listen 10.11.12.13:80
> Listen 10.11.12.14:80
< ServerRoot /www/webtst
> ServerRoot /www/webprd
< RewriteRule ^/cgi-bin/cgiweb(.*) /qsys.lib/cgilib.lib/cgiweb.pgm$1 [PT,L]
> RewriteRule ^/cgi-bin/cgiweb(.*) /qsys.lib/cgilib/cgiweb.pgm$1 [PT,L]
Look at the first pair of lines above. The "1c1" means that line 1 of the second file differs from line 1 of the first file (it would need to change to make it match—hence the "c"). The differing configuration directives instruct the production and test servers to listen for (respond to) different IP addresses. This is fine.
Our next difference is also legitimate. The notation "6c6" means that line 6—in this case, the ServerRoot—differs between the files.
The third difference is the clinker. The "54c54" shows two different RewriteRule lines. (An Apache "rewrite rule" is a powerful directive, transforming browser requests into program calls that your software understands.) Look carefully at the two RewriteRule lines. While the first directive asks for a location called cgilib.lib, the second directive asks for cgilib, omitting the final .lib. That's not good!
The "diff" utility helped us find the error, a missing .lib on a RewriteRule.
Now, press F3 to exit the PASE session.
We're done! If this were a real emergency, we'd probably correct the Web configuration using the Web-based Web Administrator.
Our example only showed changes ("c") between the two files. Depending on how extensive the files' differences were, the letters "a" (added lines) and "d" (deleted lines) might also have appeared.
For more information, see the diff command reference.
MC Press Online