Update shell.js

This commit is contained in:
Namhyeon Go 2021-06-25 04:29:07 +09:00 committed by GitHub
parent 92d23f4dff
commit 1a3c8e1b06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,23 +73,32 @@ var ShellObject = function() {
}
};
this.exec = function(cmd, stdOutPath) {
var data;
this.exec = function(cmd, stdOutPath, stdErrPath) {
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;
c += " 2>&1";
//c += " 2>&1";
c += " 2> " + stdErrPath;
this.interface.Run(c, 0, true);
console.info("ShellObject.exec() -> " + c);
data = FILE.readFile(stdOutPath, "utf-8");
if (FILE.fileExists(stdOutPath)) {
FILE.deleteFile(stdOutPath);
}
sleep(1);
return data;
if (FILE.fileExists(stdOutPath)) {
stdout = FILE.readFile(stdOutPath, "utf-8");
FILE.deleteFile(stdOutPath);
}
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) {