私はopen3を使用STDIN
してプログラムに渡し、次に読み取りと解析を行ってSTDOUT
います。e0
私のプログラムは、、e1 e2
などの形式の引数を期待しています。
新しい引数が与えられるたびに、STDOUT
変化します。引数として渡す次の数値を与える最初の結果を解析した後、次の引数を渡す方法がわかりません。これが私のコードです:
require 'open3'
require 'state_machines'
#this is for the first command e0 only
cmd = ('./pos.tx')
status1 = ''
puts "Step 1: #{cmd}"
Open3.pipeline_rw(cmd) {|stdin, stdout, wait_thrs|
stdin.write "e0\n"
stdin.close
#
status1 = stdout.read
lines3 = status1.match(/Ee\s+(.*)\s+/)
@next_states = status1.match(/\d+/)
event = status1.match(/\s+\D+\s+\n/)
#puts lines3
puts @next_states
puts event
}
次の引数は に格納され@next_states
、1 つまたは複数の数値にすることができます。この配列の要素を使用して、プログラムの次の部分に進み、再度解析するにはどうすればよいですか?