This commit is contained in:
nm1 2026-11-04 00:33:23 +05:30
commit 74ae93a96e

View file

@ -0,0 +1,19 @@
bash commands in nodejs
```js
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();
```