Skip to content

Instantly share code, notes, and snippets.

@jinwei233
Created September 16, 2011 13:10
Show Gist options
  • Save jinwei233/1222087 to your computer and use it in GitHub Desktop.
Save jinwei233/1222087 to your computer and use it in GitHub Desktop.
检验JAVA是否安装
/*
判断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