How to run interactive shell command inside node.js?

后端 未结 3 1132
梦毁少年i
梦毁少年i 2020-12-17 15:11

I have to run some interactive shell command inside node.js. Lets our interactive shell be $ python:

var cp = require(\'child_process\');
var py         


        
3条回答
  •  悲&欢浪女
    2020-12-17 15:56

    This works great for me:

    const { spawn } = require('child_process')
    const shell = spawn('sh',[], { stdio: 'inherit' })
    shell.on('close',(code)=>{console.log('[shell] terminated :',code)})
    

提交回复
热议问题