作者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
1F:→ kenmax:改成puts run('./read_from_ruby.php #{msg}') 10/16 09:53
2F:→ kenmax:讯息是说,分不出你要 puts(run, '...')或上面那个 10/16 09:57
3F:→ itucson:run("./read_from_ruby.php #{msg}") 改成这样就好了, 10/16 10:17
4F:→ itucson:感谢你 ^^ 10/16 10:17