Monday 14 May 2018

How to pipe curl into tar with node spawn

Hi guys,Im currently trying to write some function which will recive some http link and download that .tgz archive with curl and pipe it to tar which will process it. For now i have this codeconst { spawn } = require('child_process') const curl = spawn('curl', ['-s', 'some_http_link','--output','-']); // pipe pachage to stdout of curl process const tar = spawn('tar', ['-xz', '-O', 'folder/some_json_object']); // spawn tar process which should unpack curl and output data to stdout curl.stdout.pipe(tar.stdin); // pipe curl stdout to tar stdin console.log(tar.stdout); // print data (i guess) This returns some errors pastebin link hereAny ideas of how to resolve this?Bottom line, i dont want to start process with exec, i want to avoid shell. I know i can do shell one liner withcurl -s link | tar -xz -O thing_i_need.json and it will print content of thing_i_need.json to stdout, but want to avoid it. Thanks!

Submitted May 14, 2018 at 11:36AM by p3numbra_3

No comments:

Post a Comment