i am using following code in my app:
var path = app.getAppPath();
var spawn = require('child_process').spawn;
const child = exec(`"${path}\\PC-BASIC\\a.bat"`, []);
var stdout = '';
var stderr = '';
child.stdout.on('data', function(buf) {
//console.log('[STR] stdout "%s"', String(buf));
stdout += buf;
});
child.stderr.on('data', function(buf) {
//console.log('[STR] stderr "%s"', String(buf));
stderr += buf;
});
child.on('close', function(code) {
console.log('[END] code', code);
console.log('[END] stdout "%s"', stdout);
console.log('[END] stderr "%s"', stderr);
});
when i run a.bat from command line (dos). i get the exact result. but when i run it from my electron app i writes following on console:
[END] code 0
[END] stdout "
D:\Documents\Nauman Umer\New folder\electron-quick-start>"C:\Program Files (x86)\PC-BASIC\pcbasic.com" --load="ART.BAS" --convert=A
"
[END] stderr ""
but expected is:
[END] code 0
[END] stdout "
D:\Documents\Nauman Umer\New folder\electron-quick-start>"C:\Program Files (x86)\PC-BASIC\pcbasic.com" --load="ART.BAS" --convert=A
[FILE TEXT AS IN OUTPUT OF BAT]
"
[END] stderr ""
i also tried to execute pcbasic directly from command line instead of from app but the results are same.
sys.stdout.write()for writing to console.