Hello I am trying to run terminal commands from NodeJS and am trying to use the spawn command, I had been using exec but am trying spawn now for the stdout.
All the examples I've bene reading, like this one: Exec : display stdout "live"
Use commands with multiple arguments, like in the example above, the command they run with spawn is :
var spawn = require('child_process').spawn, ls = spawn('ls', ['-lh', '/usr']);
Which is '$ ls -lh /usr'
I am trying to just run the command 'pwd' with no args, but all the ways I've been trying to do so (like below) have resulted in an '' error
var spawn = require('child_process').spawn, ls = spawn('pwd');
or
var spawn = require('child_process').spawn, ls = spawn('pwd', []);
stderr: usage: pwd [-L | -P]