Websphere wsadmin.sh从stdin读取多行命令

Websphere wsadmin.sh从stdin读取多行命令,websphere,wsadmin,jacl,Websphere,Wsadmin,Jacl,Pipedwsadmin无法使用流控制运行脚本,因为在该模式下,换行符分隔命令 以下是一个简单的例子: 输出: [wasuser@oktest-prod-app-2 ~]$ ${WC_WSADMIN:?} -f test.jacl WASX7209I: Connected to process "dmgr" on node EmProdDmgrNode using SOAP connector; The type of process is: DeploymentManager 1 3 5 7

Piped
wsadmin
无法使用流控制运行脚本,因为在该模式下,换行符分隔命令

以下是一个简单的例子:

输出:

[wasuser@oktest-prod-app-2 ~]$ ${WC_WSADMIN:?} -f test.jacl
WASX7209I: Connected to process "dmgr" on node EmProdDmgrNode using SOAP connector;  The type of process is: DeploymentManager
1
3
5
7
11
13
[wasuser@oktest-prod-app-2 ~]$ ${WC_WSADMIN:?} <test.jacl
WASX7209I: Connected to process "dmgr" on node EmProdDmgrNode using SOAP connector;  The type of process is: DeploymentManager
WASX7029I: For help, enter: "$Help help"
wsadmin>1 3 5 7 11 13
wsadmin>WASX7015E: Exception running command: "foreach num $numbers {"; exception information:
 com.ibm.bsf.BSFException: error while eval'ing Jacl expression:

wsadmin>WASX7015E: Exception running command: "puts $num"; exception information:
 com.ibm.bsf.BSFException: error while eval'ing Jacl expression:
can't read "num": no such variable
    while executing
"puts $num"
wsadmin>WASX7015E: Exception running command: "}"; exception information:
 com.ibm.bsf.BSFException: error while eval'ing Jacl expression:
invalid command name "}"
    while executing
"}"
但是如果块中必须有多个命令怎么办?

使用分号:

foreach num $numbers { puts $num; puts $num }
但您最好将脚本写入一个临时文件

foreach num $numbers { puts $num }
foreach num $numbers { puts $num; puts $num }