2009-09-30 66 views
5

我在我的應用程序中使用ssh,並且必須將「-t -t」傳遞給ssh才能正常工作。否則,我的應用程序的stdin會受到ssh調用的干擾。強制僞終端的ssh通過-t -t避免了這個問題,而是導致從SSH回來以下令人費解的錯誤消息,儘管該應用程序似乎正常工作,否則:在ssh中使用僞tty導致警告

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. 

回答

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.) 

因此,這是圍繞標準輸入問題的另一種方式從調用進程正在採取並給予SSH,但是,我想了解如何使用-t時避免警告-t。

+0

你有沒有想過?我想了解這一點,因爲在我的情況下(略有不同),我不能使用'-n'。我問在https://serverfault.com/questions/851186/所以,如果適當,隨時回答,而不是在這裏。 – Davide 2017-05-19 18:01:35

+0

@Davide我在服務器故障upvoted你。就在不久前,我不記得迴避-t -t警告,但我可能會誤解。如果您在那裏得到了很好的回覆,請在此更新您的評論。 – WilliamKF 2017-05-20 02:31:12

+0

是的,這裏有一個很好的迴應,看看! – Davide 2017-05-22 21:34:32