其实我正在编写2个
的脚本a.sh
#!/bin/sh
PASSPHRASE="PASS"
for i in 1 2
do
echo "say hii:"
done
另一个剧本 b.sh
#!/usr/bin/expect -f
spawn ./a.sh
sleep 2
for {set x 1} {$x<3} {incr x} {
expect "say hii:"
send "hii\r"
sleep 10
interact
}
executing ./b.sh
所以这是第一次发送say hii: "and we are sending hii"
for the second time it getting struck in say hii:
所以我想发送两次意味着有多少时间用于循环。
答案 0 :(得分:0)
a.sh
写完后说完hii两次
#!/bin/sh
PASSPHRASE="PASS"
for i in 1 2
do
echo "say hii:"
IFS= read -r line && echo "$0 read: $line"
done
b.sh
#!/usr/bin/expect -f
spawn ./a.sh
sleep 2
for {set x 1} {$x<3} {incr x} {
expect "say hii:"
send "hii\r"
sleep 1
}
interact