[問題] 傳字串到php,再由php傳字串回來處理

看板Ruby作者 (愛吐桑)時間16年前 (2008/10/16 09:35), 編輯推噓0(004)
留言4則, 2人參與, 最新討論串1/1
環境: 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

10/16 09:53, , 1F
改成puts run('./read_from_ruby.php #{msg}')
10/16 09:53, 1F

10/16 09:57, , 2F
訊息是說,分不出你要 puts(run, '...')或上面那個
10/16 09:57, 2F

10/16 10:17, , 3F
run("./read_from_ruby.php #{msg}") 改成這樣就好了,
10/16 10:17, 3F

10/16 10:17, , 4F
感謝你 ^^
10/16 10:17, 4F
文章代碼(AID): #18zff7LH (Ruby)
文章代碼(AID): #18zff7LH (Ruby)