How to feed data over STDIN to multiple external commands in ruby.
- by Erik
This question is a bit like my previous (answered) question:
How to run multiple external commands in the background in ruby.
But, in this case I am looking for a way to feed ruby strings over STDIN to external processes, something like this (the code below is not valid but illustrates my goal):
#!/usr/bin/ruby
str1 = 'In reality a relatively large string.....'
str2 = 'Another large string'
str3 = 'etc..'
spawn 'some_command.sh', :stdin => str1
spawn 'some_command.sh', :stdin => str2
spawn 'some_command.sh', :stdin => str3
Process.waitall