Node.js: Writing a function to return spawn stdout as a string

后端 未结 3 1176
旧时难觅i
旧时难觅i 2020-12-13 14:04

I\'m trying to return the output of this function as a string, but it keeps returning as undefined. Where am I going wrong?

function run(cmd){
    var spawn          


        
3条回答
  •  抹茶落季
    2020-12-13 14:28

    var spawn = require('child_process').spawn,
        command  = spawn('ls', ['/tmp/']);
    command.stdout.pipe(process.stdout);
    

    The following link is exactly the same question as yours.

提交回复
热议问题