Created
September 16, 2011 13:10
-
-
Save jinwei233/1222087 to your computer and use it in GitHub Desktop.
检验JAVA是否安装
This file contains 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
/* | |
判断JAVA是否安装 | |
*/ | |
var spawn = require('child_process').spawn; | |
exe(["/c","python","a"]); | |
/* | |
0: success | |
1: fail at step1 | |
2: fail at step2 | |
*/ | |
function exe(command){ | |
var cmd = spawn("cmd",command); | |
cmd.stdout.setEncoding("ASCII"); | |
cmd.stdout.on("data",function(data){ | |
console.log("------------------------------"); | |
console.log("exec",command); | |
console.log("stdout:"+data); | |
}); | |
cmd.stderr.on("data",function(data){ | |
console.log("------------------------------"); | |
console.log("stderr:"+data); | |
console.log("------------------------------"); | |
}); | |
cmd.on("exit",function(code){ | |
console.log("exited with code:"+code); | |
console.log("------------------------------"); | |
}); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment