Reputation: 46389
Edit: This just got marked as a duplicate of a question on calling a Bash command. I daresay anyone familiar with programming should be aware that "calling a Bash command" is vastly different from sucking down a resource by HTTP and sending its output to another program.
Does anyone have sample code showing how to achieve this kind of thing in Ruby:
curl http://stackoverflow.com | wc
I know I could use system
, but would ideally like to keep it pure Ruby using IO.pipe
or whatnot.
Upvotes: 3
Views: 238
Reputation: 369074
Use Open3::pipeline
method. For example:
require 'open3'
Open3.pipeline(['curl', 'http://stackoverflow.com'],
['wc'])
Upvotes: 5