简体   繁体   中英

Node: ShellJS not working with command line tools

If I execute shell.exec('http') I get the help for httpie, a request library I use. However if I add an argument, like seen below, shelljs never calls the callback.

var shell = require('shelljs');

shell.exec('http http://www.example.com/', {async: true, silent: false}, function(data){
  console.log(data);
})

The above example DOES work if I use curl instead of http . Any ideas why its not working with http ?

Add ignore-stdin option

var shell = require('shelljs');
shell.exec('http --ignore-stdin http://www.example.com/', {async: true, silent: false}, function(data){
  console.log(data);
});

The --ignore-stdin option prevents HTTPie from reading data from stdin, which is usually not desirable during non-interactive invocations.

You can read more in the Scripting section of httpie

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM