Run a binary from Node.JS and relay the behavior exactly on the console, including prompts

穿精又带淫゛_ 提交于 2019-12-11 09:49:12

问题


I'm making a cli tool with Node.JS. I run another binary file from within node, and the other process asks for a password at some point.

So what I need is to simply launch the other process, and put it "in charge" of the terminal, so the other process handles the prompts and the console output.


回答1:


You can use 'inherit' for the stdio option of spawn:

const spawn = require( 'child_process' ).spawn;
spawn( '/path/to/binary', [], { stdio: 'inherit' } );


来源:https://stackoverflow.com/questions/49737328/run-a-binary-from-node-js-and-relay-the-behavior-exactly-on-the-console-includi

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