我尝试了以下方法:
set timeout -1
spawn $env(SHELL)
match_max 100000
send -- "ssh somewhere@addr"
expect "*"
for { set i 0 } { $i < [array size env] } { incr i } {
send -- "echo env($i) = $env($i)"
expect "*"
}
send -- "env > foo\r"
expect "*"
send -- "^D"
expect eof
以上失败并出现以下错误:
no such variable
(read trace on "::env(0)")
invoked from within
"send -- "echo env($i) = env($i)""
("for" body line 2)
invoked from within
"for { set i 0 } { $i < [array size env] } { incr i } {
send -- "$::env($i)"
expect "*"
}"
(file "./script.exp" line 52)
我将通过重新采购rc
文件来解决系统问题;我只想将我设置的未知变量集合(相对于脚本)传输到远程执行环境。
这可能吗,我不熟悉TCL(完全初学者)?