I am trying to control a server using nodeJS. I can correctly stop and start the server using nodeJS but sometimes, the server could fail to start because of some unexpected errors. These errors will be outputted to console. Based on these errors I would like to perform various things. To get these errors, I used the spawn function like so:
spawn('./startEngine.sh &> test.txt',[] , options);
But I seem to be getting a ENOENT error
Error: spawn ./startEngine.sh &> test.txt ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
I have also tried to include the 'output to file' option as args for the spawn function but when I do this, it seems to ignore it completely and outputs to console anyways.
spawn('./startEngine.sh',['&>', 'test.txt'] , options);
Should I be doing something differently, if not then are there any other ways of getting the output of a process into a text file? thank you in advance!
