0

Pipedwsadmin无法运行带有流控制的脚本,因为在该模式下,换行符分隔命令。

来自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 }

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

4

1 回答 1

0

使用分号:

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

但是您最好将脚本写入临时文件。

于 2015-04-10T14:08:44.523 回答