I would like to use netcat in JavaScript by using exec function. I wrote below function when I run it I am not seeing anything on my command line.
const { exec } = require('child_process');
var myScript = exec('nc -l 87',
(error, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
if (error !== null) {
console.log(`exec error: ${error}`);
}
});
PS: I know the netcat module in node.js but I want to use it with exec function.
Seemingly, problem were related with the using zsh instead of using bash. If you run your node application in the bash shell the application is giving the expected output.