ASPL User Manual v 1.00
© 2025 SetSphere.com


12-17

   Compare Program Env. Variables: progenvcompare.aspl


Two programs can be setting environment variables and we want to compare these variables. The script progenvcompare.aspl takes two arguments representing each program along its options, then display their environment variables so we can visually compare them.

Also consider a shell script that can be sourced to setup the environment variables within a user shell session. For example, consider a script that can take an argument to define shell variables specific to a Java compiler. We want to compare these variables that may include the CLASSPATH or JAVA_HOME.

In general, typing the command env after starting a program at the shell prompt,
will not reveal the environment variables being set by the program.

One can think that using the command env after starting a program will reveal the environment variables being set by the program. This is only true for these variables that have been set should the program source another shell program to set them. In general, when the program is started at the shell prompt, it is typically launched as a child process, therefore the command env is not adequate to see the environment variables being set by the program (simply because once the child terminates these variables disappear). Or may be the program starts a child process in the backgroup and returns to the prompt.

In addition, some shell scripts may bootstrap a process that starts many threads with their own environment variables. For instance, WebSphere launcher script starts a bootstrap process to launch many JVM threads. If this is the case then one need to resort to reaping the launcher process and gather the information by process id; for reaping the env, refer to reapenvcompare.aspl see SECTION 12.21.1 [Compare Reaped Environment: reapenvcompare.aspl]

For now, consider the following script that compares the environment of two shell scripts (that are meant to source the environment variables).


 -LIS- Listing. 12.17.1   [MAJOR WORDS][Script progenvcompare.aspl]
(raw text)
1.      #!/usr/bin/env aspl
2.      #ENVARG= -wsname TRANSIENT -groupingclass SYSENVGROUP -nostrictld 
3.      
4.      ;;***********************************************************************
5.      ;;   progenvcompare.aspl
6.      ;;   compare the environment variables of two sourcing shell scripts
7.      ;;   
8.      ;;   Copyright © 2025 Total Computing & Network Design, Inc.
9.      ;;   Copyright © 2021-2025 Bassem W. Jamaleddine
10.     ;;   All rights reserved.
11.     ;;***********************************************************************
12.     
13.     endScriptIfShellArgsLessThan 2  ;; end the script unless at least two 
      arguments 
14.     
15.     A = ggprogenv(grp1,L,program,$1,onlychanged,1)
16.     B = ggprogenv(grp1,L,program,$2,onlychanged,1)
17.     
18.     printblock *** COMPARING PROGRAMS ENVIRONMENT VARIABLES ***
19.     ,f& A B
20.     printblock *** IN 1st NOT IN 2nd ENVIRONMENT VARIABLES ***
21.     ,f\ A B
22.     printblock *** IN 2nd NOT IN 1st ENVIRONMENT VARIABLES ***
23.     ,f\ B A
24.     
25.     printblock *** MATCHING PROGRAMS ENVIRONMENT VARIABLES ***
26.     f&,`ks= A B
27.     printblock *** DIFFERED PROGRAMS ENVIRONMENT VARIABLES ***
28.     f&,`ks~ A B
29.     printblock *** SIMILARITY COMPARISON ***
30.     sim A B
31.     dm 3
32.     v
33.     
34.     __END__
35.     
36.       $00 command to compare the environment variables of two programs
37.       or two shell scripts.
38.     
39.          $00 must be followed by two program names
40.     
41.       Example:
42.         $00  "/tools/env/setj.sh w130"  "/tools/env/setj.sh w142"
43.         $00  "/tools/env/setj.sh j160"  "/tools/env/setj.sh w160"
44.     

ASPL© 2025 Bassem Jamaleddine






The following shows how to compare the environment variables between distributions of IBM WebSphere.
viewme

 -TC- Display. 12.17.1   [Script progenvcompare.aspl]
progenvcompare.aspl script to compare two WebSphere distributions environment variables


The following shows how to compare the environment variables between two WebSphere shell scripts: stopNode.sh and runConfigActions.sh.
viewme

 -TC- Display. 12.17.2   [Script progenvcompare.aspl]
progenvcompare.aspl script