类似于使用node | tee out.txt
可以把 node 中输出的内容不仅输出到屏幕终端,还可以输出到文件out.txt
。
那怎么样做才能把不影响向终端中正常输入内容,同时把输入的内容保存一份到文件中,作为记录呢?
是要对/dev/stdin
动手脚吗?
RTRT 谢谢各位了!
![]() |
1
andyfan 197 天前 via Android
有一个命令叫 history
|
![]() |
2
thedrwu 197 天前 via Android
tee in.txt | node
|
![]() |
5
lululau 197 天前
tee out.txt | node
另外,虽然标准 IO 默认指向终端,但是它和终端不是一个概念,标题应该把终端改为标准输入 |
![]() |
6
tuduweb OP |
![]() |
7
lululau 197 天前
brew install ttyrec
man ttyrec man ttyplay |
![]() |
8
sisylocke 197 天前
不行的,在 stdout 进程结束前终端不能读取 stdin ,你需要的是 readlineSync 之类的工具。
|
9
zhlxsh 197 天前 via iPhone
你要做的原本的事情是什么,我觉得有可能通过其他方法去完成你的要求
|
![]() |
10
lululau 197 天前
其实 tee out.txt | node 这个方法是对的,你说的阻塞了 node 的交互信息输出,是因为 node 判断了如果标准输入不是 tty 则默认启用 script mode ,可以加 -i 参数强制 interactive mode
tee out.txt | node -i |
![]() |
11
hsfzxjy 197 天前 via Android
你是要 script 命令吧
|