initial
This commit is contained in:
commit
74ae93a96e
1 changed files with 94691 additions and 0 deletions
|
|
@ -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();
|
||||
|
||||
```
|
||||
Loading…
Reference in a new issue