sh在ssh之后删除所有行

时间:2019-05-24 09:01:39

标签: linux bash ssh sh

考虑以下文本文件
test-1

echo "hello"
echo "cruel"
echo "world"

发出以下命令:

bash < test-1

所有3行都被执行。

现在,让我们介绍一下文件中的一些变化
test-2

echo "hello"
ssh username@192.168.0.100 "echo HELLO > /tmp/file"; echo "cruel"
echo "world"

使用

运行
bash < test-2

仅执行以下命令:

echo "hello"
ssh username@192.168.0.100 "echo HELLO > /tmp/file"
echo "cruel"

最后一行或实际上包含 ssh 的行之后的任何行都将被忽略!
为什么?
以及如何解决?

问题似乎与 bash 有关。
例如在Ubuntu上的问题sh < test-2,其中 sh 不是 bash ,并且所有行都将正确执行,但是在CentOS上,其中 sh < / strong>映射到 bash ,包含 ssh 的一行之后的所有行将被删除。

0 个答案:

没有答案