I am using this pattern to execute bash scripts:
const exec = util.promisify(require('child_process').exec);
async function myBash() {
try {
const { stdout, stderr } = await exec("echo hi");
console.log(stdout);
} catch (err){
console.error(err);
};
};
How can I pass the variable greeting to the exec command - non working:
const exec = util.promisify(require('child_process').exec);
const greeting = "hello";
async function myBash(greeting) {
try {
const { stdout, stderr } = await exec("echo", greeting);
console.log(stdout);
} catch (err){
console.error(err);
};
};