Skip to content

Instantly share code, notes, and snippets.

@Choirrulloh
Forked from harrypujols/execute.js
Created March 2, 2021 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Choirrulloh/e885147e0c1d81ab86c8afad8f5748ab to your computer and use it in GitHub Desktop.
Save Choirrulloh/e885147e0c1d81ab86c8afad8f5748ab to your computer and use it in GitHub Desktop.
Execute shell command in javascript
#!/usr/bin/env node
function execute(command) {
const exec = require('child_process').exec
exec(command, (err, stdout, stderr) => {
process.stdout.write(stdout)
})
}
execute('echo "Hello World!"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment