Skip to content

Instantly share code, notes, and snippets.

@sytranvn
Forked from harrypujols/execute.js
Created July 16, 2018 05:03
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 sytranvn/e6705f2b3068e07a625c0e23fafb8bd7 to your computer and use it in GitHub Desktop.
Save sytranvn/e6705f2b3068e07a625c0e23fafb8bd7 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