【发布时间】:2017-03-15 21:06:04
【问题描述】:
这是我的期望脚本用例(我拥有的少数脚本之一)
我想通过 ssh 运行多个 sed 命令。它就像预构建环境设置。
我想运行这样的东西:-
#!/usr/bin/expect
set timeout -1
spawn -noecho bash -c "ssh -t user@host 'sed -i <some_stuff1> <file1>'"
spawn -noecho bash -c "ssh -t user@host 'sed -i <some_stuff2> <file2>'"
spawn -noecho bash -c "ssh -t user@host 'sed -i <some_stuff3> <file3>'"
expect {
-re ".*sword.*" {
exp_send "$env(PASS_WORD)\n"
exp_continue
}
}
但只有最后一个sed 命令会执行。第 1 次和第 2 次将被跳过。
我错过了什么隐藏的宝石?
这是我目前看到但没有帮助的内容
Handle multiple statement in expect script
Expect script: How to handle two processes?
Handling multiple process simuntaneously - safari online book
【问题讨论】: