nodeJS exec funktioniert nicht für "cd" shell cmd
var sys = require('sys'),
exec = require('child_process').exec;
exec("cd /home/ubuntu/distro", function(err, stdout, stderr) {
console.log("cd: " + err + " : " + stdout);
exec("pwd", function(err, stdout, stderr) {
console.log("pwd: " + err + " : " + stdout);
exec("git status", function(err, stdout, stderr) {
console.log("git status returned " ); console.log(err);
})
})
})
cd: null :
pwd: null : /
git status returned
{ [Error: Command failed: fatal: Not a git repository (or any of the parent directories): .git ] killed: false, code: 128, signal: null }
nodeJS exec funktioniert nicht für "cd" shell cmd. Wie Sie unten sehen, funktioniert pwd. Der Git-Status versucht zu funktionieren, schlägt jedoch fehl, da er nicht in einem Git-Verzeichnis ausgeführt wird. cd cmd bricht jedoch die weitere erfolgreiche Ausführung anderer Cmds nicht ab. Versucht in NodeJS Shell sowie NodeJS + ExpressJS Webserver.