Search code examples
shellunixwebspherewebsphere-8system-variable

How to figure out an Environment Entry from Websphere via Unix shell


I develop using Websphere 8.5 in Windows machine but the Tests and Prod are Websphere 8.5 on Mainframe. The application MyApp depends on certain System Environment named MyApp_Env. Basicaly, this System Environment tells which environment is running (Dev, Test, Prod). In windows, I set up as System Environment. When this application goes to mainframe for users tests, in Websphere 8.5 running on Mainframe, such variable is set up in Application Servers > MyServer > Process Definition > Servant > Environment Entries. I do have access to Test Websphere Admin console so I can see it. For some local reasons, I don't have access to Prod Websphere Admin console and I want to see this variable value. I have access to ishell so I tried four alternatives, (1) echo $MyApp_Env, (2) set MyApp_Env, (3) env MyApp_Env, (4) printenv MyApp_Env. I tried to find by looking for one by one after simple printenv and env with no success. So, my question is how can I discovery the value of MyApp_Env via Unix shell? I am sure the variable is there as one of Websphere Servant.Environment Entries but how to print it? I guess that I can't see the variables because it doesn`t belong to the environment variables of the shell that is running into the terminal. But, certainly, there must exist some way to see the environment variables available for other process different from the terminal opened.


Solution

  • Although you don't have access to admin console of the Prod machine, I'm assuming you have the ability to run wsadmin on it from a Unix shell. If so, use a text editor to create a script file named myScript similar to the following and run it using: wsadmin -f /pathToScript/myScript.jacl

    #get the config id of server, change Cell, Node and Server values for your env
    set server1 [$AdminConfig getid /Cell:myCell/Node:myNode/Server:myServer]
    # assume there is only one process definition, if there are more, you will need loop over them
    set proc [$AdminConfig list JavaProcessDef $server1]
    # get the list of environment entries for the process definition
    set envs [lindex [$AdminConfig showAttribute $proc environment] 0]
    # loop over them and display name and value of each
    foreach propEntry $envs {
      puts [$AdminConfig showAttribute $propEntry name]
      puts [$AdminConfig showAttribute $propEntry value]
    }