-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not getting complete stdout #8807
Comments
I think this is happening to me. In this example I see output in os x but not in ubuntu/docker. Using node 6.7.0 test.js
script.sh
|
/cc @Fishrock123 |
Are either of you calling |
@Fishrock123 the process is exited automatically after execution |
maybe @bnoordhuis or @cjihrig? |
@nodejs/platform-windows |
I'll give this a look but if the issue in the OP is about |
@naumanumer I just tried the attached app with <!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>stdout</h1>
<pre id=stdout></pre>
<h1>stderr</h1>
<pre id=stderr></pre>
<h1>stdout</h1>
<pre id=exitline></pre>
</body>
<script>
const spawn = require('child_process').spawn;
const ls = spawn(`${__dirname}/ls.bat`, []);
ls.stdout.on('data', (data) => {
document.getElementById('stdout').innerHTML += data.toString().replace(/</g, '<');
});
ls.stderr.on('data', (data) => {
document.getElementById('stderr').innerHTML += data;
});
ls.on('close', (code) => {
document.getElementById('exitline').innerHTML += `child process exited with code ${code}\n`;
});
</script>
</html> with dir *.* |
Also, |
@bzoz I don't think spawn needs a shell to call .bat files. It does for .cmd files (which is what npm uses to wrap node CLIs), but .bat, .com, and .exe are considered executable and can be directly spawned unless I very much misremember. Or perhaps the key is "reliably", is there something unreliable about .bat files run without a shell? |
I think "reliably" is indeed the key point. |
Version: v4.4.7
Platform: windows 10 (64 bit)
a.bat
its ouput when executed from command line:
pcbasic is written in python and using
sys.stdout.write()
instead ofprint
.but when I run this bat file with from my electron app using to about javascript code it results
I also tried
spawn
,exec
andexecFile
but getting same issue. and i also tried to execute pcbasic directly from program instead of from batch file but getting same problem. when i tried to redirect pcbasic output to file i noticed that a file is created but it is empty.I tried following to redirect:
The text was updated successfully, but these errors were encountered: