Last active
December 19, 2015 09:09
-
-
Save cliffano/5931066 to your computer and use it in GitHub Desktop.
child_process bg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> cat blah.js | |
var cp = require('child_process'); | |
var c = cp.exec('./blah.sh &', function (err) { | |
if (err) { | |
console.error('err: ' + err.message); | |
} else { | |
console.log('done'); | |
} | |
}); | |
c.stderr.on('data', function (data) { | |
console.error('stderr: ' + data); | |
}); | |
c.stdout.on('data', function (data) { | |
console.log('stdout: ' + data); | |
}); | |
>>> cat blah.sh | |
#!/bin/bash | |
for x in {1..5} | |
do | |
echo "numero: $x" | |
sleep 2 | |
done | |
>>> node blah.js | |
(won't exit until blah.sh is done even though it's meant to run in the background) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment