I'm using NodeJS childprocess to run shell commands on NodeJS / Express server (localhost). Everything goes well with basic shell commands like 'ls' (from NodeJS documentation):
const { spawn } = require('child_process');
const ls = spawn('ls', ['-lh', '/usr']);
ls.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ls.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
ls.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
Now, what I need to do is run a binary file that has shared object dependencies. The objects are located inside server folder 'public/libraries'. I've tried to modify the previous with
const runBinary = spawn('/path/to/binary/file', ['-someoption', 'public/libraries']);
The error message is 'error while loading shared libraries ... no such file or directory', meaning the shared objects are not found. I have no idea how to
1) tell 'runBinary' the location of the folder of shared objects, and then
2) run the binary successfully to create output in console.
I have all the necessary tools installed to run the binary in a Bash shell and have tested it works as it should.
Any ideas?