Piping data to Linux program which expects a TTY (terminal)

别来无恙 提交于 2019-11-26 11:09:50

问题


I have a program in Linux which refuses to run if its stdin/stdout is not a TTY (terminal device). Is there an easy-to-use tool which will create a PTY, start the program with the newly created TTY, and copy all data over stdin/stdout?

The use case is not interactive, but scripting. I\'m looking for the most lightweight solution, preferably not creating TCP connections, and not requiring too many other tools and libraries to be installed.


回答1:


unbuffer, part of expect (sudo apt-get install expect-dev on Ubuntu Lucid), can fool a program into thinking it's connected to a TTY.

$ tty 
/dev/pts/3
$ echo | tty 
not a tty
$ echo | unbuffer tty 
/dev/pts/11


来源:https://stackoverflow.com/questions/4233808/piping-data-to-linux-program-which-expects-a-tty-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!