This repository was archived by the owner on Dec 22, 2023. It is now read-only.
sys.spawn('foo.exe').stderr #44
Answered
by
c-smile
GirkovArpa
asked this question in
Q&A
Replies: 1 comment
-
<html>
<head>
<title>Test</title>
<style>
plaintext { display:block; size:*; border:1dip solid;}
plaintext > text.stderr { background: pink; }
</style>
<script type="module">
import * as sys from '@sys';
import * as env from '@env';
import * as sciter from '@sciter';
const out = document.$("plaintext");
const EOL = env.PLATFORM == "Windows" ? "\r\n" : "\n";
var tracert;
async function pipeReader(pipe, name) {
try {
var cline = "";
reading: while(pipe) {
var text = await pipe.read();
text = sciter.decode(text);
while(text) {
var eolpos = text.indexOf(EOL);
if(eolpos < 0) { cline += text; continue reading; }
cline += text.substr(0, eolpos);
text = text.substr(eolpos + EOL.length);
out.append(<text class={name}>{ cline }</text>);
cline = "";
}
}
} catch(e) {
out.append(<text class="error">{ e.toString() }</text>);
}
}
document.on("click", "#exec", function() {
var cmd = env.PLATFORM == "Windows" ? "tracert" : "traceroute";
tracert = sys.spawn([cmd,"sciter.com"], { stdout:"pipe", stderr:"pipe"} );
pipeReader(tracert.stdout,"stdout");
pipeReader(tracert.stderr,"stderr");
});
</script>
</head>
<body>
<button #exec>Show trace route</button>
<plaintext></plaintext>
</body>
</html> Just in case, source of sys.spawn is here: https://github.com/saghul/txiki.js/blob/master/src/process.c There is no documentation for txiki unfortunately. I will start documenting all methods in Sciter.JS modules next week. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
GirkovArpa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How does one go about reading from stderr?
Beta Was this translation helpful? Give feedback.
All reactions