作者itucson (愛吐桑)
看板Ruby
標題[問題] 傳字串到php,再由php傳字串回來處理
時間Thu Oct 16 09:35:02 2008
環境:
Ruby 1.8.6
msg_to_php.rb
msg="我輸入一串字"
def run(cmd, input='')
IO.popen(cmd,'r+') do |io|
io.puts input
io.close_write
return io.read
end
end
puts run './read_from_ruby.php #{msg}'
結果跑出
./msg_to_php.rb:13: warning: parenthesize argument(s) for future version
請問有沒有其它的方法能做到字串傳到一寫好php程式,再把php傳回的字串繼續處理?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.17.173.206
→ kenmax:改成puts run('./read_from_ruby.php #{msg}') 10/16 09:53
→ kenmax:訊息是說,分不出你要 puts(run, '...')或上面那個 10/16 09:57
→ itucson:run("./read_from_ruby.php #{msg}") 改成這樣就好了, 10/16 10:17
→ itucson:感謝你 ^^ 10/16 10:17