问题在于Debian Jessie服务器。
我使用ssh运行一个远程命令,如下所示。
#! /bin/bash
ssh root@srv01 << 'STOP_SERVER'
touch /tmp/testFile
STOP_SERVER这是可行的,只是我得到了很多我不想要的输出。下面是一个用恒星代替敏感信息的例子。
root@home:~# ./test.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
Linux srv01.***.*** 3.14.32-xxxx-grs-ipv6-64 #5 SMP Wed Sep 9 17:24:34 CEST 2015 x86_64 GNU/Linux
server : ***
ip : ***
hostname : srv01.***.***
stdin: is not a tty如果我将脚本更改为以下内容
#! /bin/bash
ssh root@srv01 << 'STOP_SERVER' >> /dev/null
touch /tmp/testFile
STOP_SERVER我得到以下输出
root@home:~# ./test.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
stdin: is not a tty如果我将选项-q添加到ssh命令中,就会得到
root@home:~# ./test.sh
stdin: is not a tty这就是我陷入困境的地方,因为我不知道如何重新编织stdin: is not a tty。
我希望能够避免输出重定向到/dev/null。这只是我不想看到的登录消息。
发布于 2020-10-17 18:00:18
我刚找到解决办法。
而不是写作
#! /bin/bash
ssh root@srv01 << 'STOP_SERVER'
date
touch /tmp/testFile
STOP_SERVER写出以下内容
#! /bin/bash
ssh root@srv01 '
date
touch /tmp/testFile
'没问题了。
https://unix.stackexchange.com/questions/615000
复制相似问题