Category : child-process

I am writing a script to downscale some images using IrfanView. When call execFile with these parameters: child_process.execFile( ""C:Program FilesIrfanViewi_view64.exe"", [ ‘D:IMAGEPATH20170630_195539.jpg’, ‘/resize=(256,192)’, ‘/resample’, ‘/convert="D:IMAGEPATH20170630_195539_small.jpg"’ ], { cwd: ‘D:IMAGEPATH’, windowsHide: true } ); I also tried to run the path without the quotes, but I also get an error. I get this error: Trace: Error: ..

Read more

I am trying to get the lines a (‘never ending’) python script puts into stdout. But currently my code would only log something to the console when the python process exits. Is there a way I can get the ‘live’ output of the python script line by line? spawn_child.js: let execFile = require("child_process").execFile; var child ..

Read more

startServer = function(path) { console.log("Starting …"); server = spawn("java", ["-jar", path], { shell: true, }); server.stdin.write("example-input"); server.stdin.end(); } I have the above (lightly edited) JavaScript, running in Node.js. The stdin input stream for the child process spawned using spawn() appears to only be sent once stdin.end() is called, at least according to my research. However, ..

Read more

I have a Nodejs project that I’m working on and I’ve cam across an issue that I can’t seem to fix. example.js const {exec} = require(‘child_process’); exec(`sh ./worker/lib/scripts/hi.sh`, (error, out) => { if (error) { console.log(`error: ${error.message}`); return; } else if (out) { console.log(`stderr: ${out}`); return; } }); hi.sh echo "hi" I run the code ..

Read more

I’m interacting with a child process through stdio, and I need to wait for a line from childProcess.stdout each time I write some command to childProcess.stdin. It’s easy to wrap an asynchronous method for writing like below: async function write(data){ return new Promise(resolve=>{ childProcess.stdin.write(data,()=>resolve()); }) } However, it turns out quite difficult when it comes ..

Read more