期望脚本变量赋值
expect script variable assignment
#!/usr/bin/expect
set NUM [exec some command to ssh to a remote machine and return a number]
puts $NUM
while { $NUM != "0" } {
set NUM [exec some command to ssh to a remote machine and return a number]
sleep 5
}
以上是我的代码。它在 expect 脚本中运行。我想将变量 NUM 分配给某个通过 ssh 连接到远程机器的命令和 return 一个数字(当我在终端中键入时,此命令将 return 一个数字)。
我得到了错误:
100
while executing
"exec some command to ssh to a remote machine and return a number "qstat | wc -l""
invoked from within
"set JOBS [exec some command to ssh to a remote machine and return a number "qstat | wc -l"]"
问题是我得到了数字,但我未能将该数字分配给变量 NUM
谁能帮我调试一下这块?谢谢
Ton 不能这样做,因为它是一个 expect 脚本,最好的方法是将 expect 脚本包装在 bash 脚本中。见 Run expect command inside while loop in shell script
#!/usr/bin/expect
set NUM [exec some command to ssh to a remote machine and return a number]
puts $NUM
while { $NUM != "0" } {
set NUM [exec some command to ssh to a remote machine and return a number]
sleep 5
}
以上是我的代码。它在 expect 脚本中运行。我想将变量 NUM 分配给某个通过 ssh 连接到远程机器的命令和 return 一个数字(当我在终端中键入时,此命令将 return 一个数字)。 我得到了错误:
100
while executing
"exec some command to ssh to a remote machine and return a number "qstat | wc -l""
invoked from within
"set JOBS [exec some command to ssh to a remote machine and return a number "qstat | wc -l"]"
问题是我得到了数字,但我未能将该数字分配给变量 NUM
谁能帮我调试一下这块?谢谢
Ton 不能这样做,因为它是一个 expect 脚本,最好的方法是将 expect 脚本包装在 bash 脚本中。见 Run expect command inside while loop in shell script