我在我的应用程序中使用ssh并且必须将“-t -t”传递给ssh才能使其正常工作。否则,我的应用程序的标准输入受到ssh调用的干扰。通过-t -t强制伪终端ssh可以避免这个问题,但是会导致从ssh返回的以下模糊错误消息,尽管应用程序似乎正常工作:
tcgetattr: Inappropriate ioctl for device
我想摆脱这个消息,以防止它发生,而不是只是压抑它,但我不知道为什么它会来,我应该怎么做以防止它。当-t -t传递给ssh时,我只收到消息。
注意这里有一个类似的问题:
http://www.perlmonks.org/?node_id=664789
ssh的手册页说:
-t Force pseudo-tty allocation. This can be used to execute arbitrary
screen-based programs on a remote machine, which can be very useful,
e.g., when implementing menu services. Multiple -t options force tty
allocation, even if ssh has no local tty.
答案 0 :(得分:4)
可以通过将-n传递给ssh而不是-t -t来解决此问题。从ssh手册页:
-n Redirects stdin from /dev/null (actually, prevents reading from
stdin). This must be used when ssh is run in the background. A
common trick is to use this to run X11 programs on a remote
machine. For example, ssh -n shadows.cs.hut.fi emacs & will
start an emacs on shadows.cs.hut.fi, and the X11 connection will
be automatically forwarded over an encrypted channel. The ssh
program will be put in the background. (This does not work if
ssh needs to ask for a password or passphrase; see also the -f
option.)
所以这是围绕stdin从调用进程中获取并给予ssh的问题的另一种方法,但是,我想了解如何在使用-t -t时避免警告。