我有一个bash脚本,我使用ssh
连接到另一台服务器并在那里运行一些命令。我发现一些网站的错误(Warning: no access to tty (Bad file descriptor). Thus no job control in this shell.
)是一个友好的消息,但我的bash脚本得到“卡住”。出现此消息后,不会执行其他命令。其他论坛表示使用ssh -t
压制邮件,但它不适合我。我的代码看起来是这样的:如何摆脱“没有访问tty(坏文件描述符)”消息在bash中?
.
.
.
stty -echo
sshpass "pwd" ssh -o StrictHostKeyChecking=no [email protected] 'su -lc "rm -rf tmp"' 2>/dev/null
stty echo
.
.
.
为什么我使用stty-echo
的原因是因为我需要用户切换到root,密码显示在终端(我不想)上。在连接服务器(ip:1.1.1.1)上输入root密码后,我收到错误消息(Warning: no access to tty (Bad file descriptor). Thus no job control in this shell.
)。
有什么建议吗?让我知道是否需要进一步的解释。谢谢! (我的bash的版本是GNU bash的版本,51年2月3日(1))
编辑
错误信息删除2>/dev/null
当我得到的是:
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
stty: standard input: Invalid argument
是否使用'-t'选项去除消息? – arco444 2014-08-27 15:46:30
@ arco444已经尝试过,并没有摆脱问题 – Alias 2014-08-27 15:50:20