wsadmin.sh从stdin读取多行命令

时间:2015-04-10 11:53:52

标签: websphere wsadmin jacl

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

来自http://www-01.ibm.com/support/knowledgecenter/SSEQTP_7.0.0/com.ibm.websphere.base.iseries.doc/info/iseries/ae/cxml_jacl.html?lang=en的简单示例:

set numbers {1 3 5 7 11 13}
foreach num $numbers {
    puts $num
}

输出:

[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 }

但如果块中必须有多个命令怎么办?

1 个答案:

答案 0 :(得分:0)

使用分号:

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

但是你可能最好将脚本写入临时文件。