1

I need to kextunload driver.kext && kextload driver.kext.

I always use child_proces spawn function but don't know how to chain with it.

Here's an example of how I use it

var spawn = require('child_process').spawn
spawn('afplay', ['fanfare.mp3', '-t', '6']);
1

1 Answer 1

2

If you don't need the streaming capabilities of spawn(), you could just easily use exec() instead, like:

var exec = require('child_process').exec;
exec('kextunload driver.kext && kextload driver.kext', function(err, stdout, stderr) {
  // ...
});
Sign up to request clarification or add additional context in comments.

4 Comments

And if he do need streaming? :-P
@JanJůna Then use spawn()? For programs/commands like 'kextload'/'kextunload', there really isn't any need to stream the output.
For other commands, it can be important to stream output instead of buffering it into memory (which can result in Max buffer size error). I found out that Node v6 has new option parameter shell: true/false which will run whole command so you can just call let spawnProcess = spawn("ls && ls && ls", {shell: true}) and it will work.
@JanJůna Right, you could use that config option for node v6+.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.