On Wed, 20 Sep 2006, Caio Chassot wrote:

>
> On 2006-09-19, at 21:45 , Paul Lutus wrote:
>
>> 
>> Could you be a bit more clear? Do you want to write a program that will
>> cooperate with a stream? As in:
>> 
>> data_source | ruby-program | data_dest
>> 
>> Yes?
>
>
> No, from within a ruby program I want to call some shell command to act on 
> data stored in a ruby string, so, in the ruby program, something like, in 
> pseudoruby:
>
> output = system('shell_cmd --params etc', :input => a_string)

harp:~ > cat a.rb
require 'open4' # gem install open4
require 'yaml'

stdin = 'foobar'
stdout = ''
stderr = ''

Open4.spawn 'cat', :stdin => stdin, :stdout => stdout, :stderr => stderr

y 'stdout' => stdout
y 'stderr' => stderr



harp:~ > ruby a.rb
---
stdout: foobar
---
stderr: ''



-a
-- 
in order to be effective truth must penetrate like an arrow - and that is
likely to hurt. -- wei wu wei