Piping an interactive session to a file

巧了我就是萌 提交于 2019-11-27 20:50:05

The simpler form could be

tee >(myprogram) | tee -a file.log

If you want to prevent input being shown again to the screen:

tee -a file.log | myprogram | tee -a file.log

script — make typescript of terminal session:

script -c "myprogram" file.log

The whole session will be logged to file.log

As two processes can't read the same input two tees are needed, one which reads terminal input and writes to program standard input and file.log another which reads program standard output and writes into terminal output and file.log:

tee -a file.log | program | tee -a file.log

An easy way is to use the script command. It just stores your whole terminal session. Run it with:

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