378 B
378 B
bash commands in nodejs
const { exec } = require('child_process');
const util = require('util');
const execPromise = util.promisify(exec);
async function runCommand() {
try {
const { stdout, stderr } = await execPromise('echo "Hello from Bash!"');
console.log(stdout);
} catch (error) {
console.error(`Error: ${error.message}`);
}
}
runCommand();