0
這個問題在STDIN喂數據給多個外部命令是有點像我以前的(回答)問題:如何紅寶石
How to run multiple external commands in the background in ruby
但是,在這種情況下,我正在尋找一種方式來養活Ruby字符串標準輸入到外部進程,像這樣(下面的代碼是無效的,但說明我的目標):
#!/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
你不需要的。只是一個Thread.new應該工作。 – Luis 2011-01-14 11:21:30