Skip to content

Instantly share code, notes, and snippets.

@kiryuxxu
Created May 12, 2017 08:23
Show Gist options
  • Save kiryuxxu/113886d0a5ead003a48b1ee54fa418b0 to your computer and use it in GitHub Desktop.
Save kiryuxxu/113886d0a5ead003a48b1ee54fa418b0 to your computer and use it in GitHub Desktop.
wget with child_process.spawn
stderr: --2017-05-12 17:21:27-- http://example.com/
Resolving example.com... 93.184.216.34, 2606:2800:220:1:248:1893:25c8:1946
Connecting to example.com|93.184.216.34|:80...
stderr: connected.
stderr: HTTP request sent, awaiting response...
stderr: 304 Not Modified
stderr: File ‘~/tmp/index.html’ not modified on server. Omitting download.
exit: 0
const spawn = require('child_process').spawn;
const cmd = spawn('wget', ['http://example.com', '-N', '-P', '~/tmp']);
cmd.stdout.on('data', (data) => {
console.log('stdout: ' + data.toString());
});
cmd.stderr.on('data', (data) => {
console.log('stderr: ' + data.toString());
});
cmd.on('exit', (code) => {
console.log('exit: ' + code);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment