0
0
PIPrince Igwe
This code will execute the ./<path> bashscript.sh command, and will print the following output:
stdout:
./test.sh: line 1: syntax error near `;' ./test.sh: line 2: unexpected ')'
stderr:
error:
./test.sh: line 1: syntax error near `;' ./test.
import {exec} from 'node:child_process'
exec('sh ./<path /to /the /bashcript.sh> ', (error, stdout, stderr) => {
if(error) {
console.log(`error: ${error.message}`)
return;
}
if(stderr) {
console.error(`stderr: ${stderr}`)
return
}
console.log(`stdout: \n${stdout}`)
})