我有一个脚本,它从循环中的管道读取并在循环中运行一个期望脚本和一个普通的 shell 脚本。这两个脚本都运行 ssh 到另一台服务器以获取一段数据。例如:
cat /tmp/file |
while read a b c d
do
s=`expect-script server1 $b`
c=`ssh $b normal-script`
echo $s $c
done
Run Code Online (Sandbox Code Playgroud)
即使 /tmp/file 中有很多行,脚本也会在处理第一行后退出。我怀疑预期脚本正在吞噬所有标准输入,因此当它返回时,没有任何东西可以阅读。我怎样才能避免这种情况?我不希望我调用的任何脚本从主脚本的 stdin 中读取。