我正在尝试做与“相反”的事情检测 stdin 是终端还是管道? https://stackoverflow.com/questions/1312922/detect-if-stdin-is-a-terminal-or-pipe-in-c-c-qt".
我正在运行一个正在更改其输出格式的应用程序,因为它在 STDOUT 上检测到管道,并且我希望它认为它是一个交互式终端,以便在重定向时获得相同的输出。
我想把它包裹在一个expect
脚本或使用proc_open()
在 PHP 中可以做到这一点,但事实并非如此。
有什么想法吗?
Aha!
The script
命令执行我们想要的...
script --return --quiet -c "[executable string]" /dev/null
有窍门吗!
Usage:
script [options] [file]
Make a typescript of a terminal session.
Options:
-a, --append append the output
-c, --command <command> run command rather than interactive shell
-e, --return return exit code of the child process
-f, --flush run flush after each write
--force use output file even when it is a link
-q, --quiet be quiet
-t[<file>], --timing[=<file>] output timing data to stderr or to FILE
-h, --help display this help
-V, --version display version
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)