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) Okay, try this: -------------------------------- #!/usr/bin/ruby -w s = "avast arlington always" output = `echo #{s} | perl -pe "s/a/x/g"` p output -------------------------------- Output: "xvxst xrlington xlwxys\n" I want to emphasize there are a dozen ways to do this. This one happens to be simple to understand. Another way is File.popen(), but that approach makes bidirectional communications difficult. -- Paul Lutus http://www.arachnoid.com