如何通过 Unix 从 Websphere 找出环境条目 shell

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

我在 Windows 机器上使用 Websphere 8.5 进行开发,但测试和生产是大型机上的 Websphere 8.5。应用程序 MyApp 依赖于名为 MyApp_Env 的特定系统环境。基本上,这个系统环境告诉了哪个环境是 运行(开发、测试、生产)。在 windows 中,我设置为系统环境。当此应用程序进入大型机进行用户测试时,在大型机上的 Websphere 8.5 运行 中,此类变量设置在 Application Servers > MyServer > Process Definition > Servant > Environment Entries 中。我确实有权访问 Test Websphere 管理控制台,所以我可以看到它。由于某些本地原因,我无权访问 Prod Websphere 管理控制台,我想查看此变量值。我可以访问 ishell 所以我尝试了四种选择,(1) echo $MyApp_Env, (2) set MyApp_Env, (3) env MyApp_Env, (4)打印环境MyApp_Env。我试图通过在简单的 printenv 和 env 之后一个一个地寻找但没有成功。 所以,我的问题是如何通过 Unix shell 发现 MyApp_Env 的值?我确定该变量作为 Websphere Servant.Environment 条目之一存在,但如何打印它?我想我看不到这些变量是因为它不属于 运行 进入终端的 shell 的环境变量。但是,当然,必须存在某种方式来查看可用于与打开的终端不同的其他进程的环境变量。

虽然您无权访问 Prod 机器的管理控制台,但我假设您有能力从 Unix shell 在其上 运行 wsadmin。如果是这样,请使用文本编辑器创建一个名为 myScript 的脚本文件,类似于以下内容并 运行 使用: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]
}