mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 12:41:04 +00:00
Update shell.js
This commit is contained in:
parent
92d23f4dff
commit
1a3c8e1b06
25
lib/shell.js
25
lib/shell.js
|
@ -73,23 +73,32 @@ var ShellObject = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.exec = function(cmd, stdOutPath) {
|
this.exec = function(cmd, stdOutPath, stdErrPath) {
|
||||||
var data;
|
var stdout, stderr;
|
||||||
|
var stdOutPath = (typeof(stdOutPath) === "undefined" ? "stdout.txt" : stdOutPath);
|
||||||
|
var stdErrPath = (typeof(stdErrPath) === "undefined" ? "stderr.txt" : stdErrPath);
|
||||||
|
|
||||||
if (typeof(stdOutPath) === "undefined") {
|
|
||||||
stdOutPath = "stdout.txt";
|
|
||||||
}
|
|
||||||
var c = "%comspec% /c (" + this.build(cmd) + ") 1> " + stdOutPath;
|
var c = "%comspec% /c (" + this.build(cmd) + ") 1> " + stdOutPath;
|
||||||
c += " 2>&1";
|
//c += " 2>&1";
|
||||||
|
c += " 2> " + stdErrPath;
|
||||||
this.interface.Run(c, 0, true);
|
this.interface.Run(c, 0, true);
|
||||||
console.info("ShellObject.exec() -> " + c);
|
console.info("ShellObject.exec() -> " + c);
|
||||||
data = FILE.readFile(stdOutPath, "utf-8");
|
sleep(1);
|
||||||
|
|
||||||
if (FILE.fileExists(stdOutPath)) {
|
if (FILE.fileExists(stdOutPath)) {
|
||||||
|
stdout = FILE.readFile(stdOutPath, "utf-8");
|
||||||
FILE.deleteFile(stdOutPath);
|
FILE.deleteFile(stdOutPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
if (FILE.fileExists(stdErrPath)) {
|
||||||
|
stderr = FILE.readFile(stdErrPath, "utf-8");
|
||||||
|
FILE.deleteFile(stdErrPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
//console.log("[stdout] " + stdout);
|
||||||
|
//console.log("[stderr] " + stderr);
|
||||||
|
|
||||||
|
return stdout;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.run = function(cmd, fork) {
|
this.run = function(cmd, fork) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user