Skip to content

Instantly share code, notes, and snippets.

@EmmanuelKasper
Last active August 8, 2018 08:37
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 EmmanuelKasper/1f694c6b0667fddf509987cbdc0906e6 to your computer and use it in GitHub Desktop.
Save EmmanuelKasper/1f694c6b0667fddf509987cbdc0906e6 to your computer and use it in GitHub Desktop.
Nodejs shell like programming: calling an external command and returning output to stdout
#! env node
// execFileSync will call the command directly without using a shell, a tad faster and prevents interpretation of characters
// ( similar to C and java exec )
const exec = require('child_process').execFileSync;
// inherit will use the stdio of the parent process, ie this nodejs script
exec('wget', ['https://git.kernel.org/torvalds/t/linux-4.18-rc8.tar.gz', '--output-document', '/tmp/bla'], {stdio:'inherit'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment