Rubyから外部プログラムを呼び出して、 パイプを使ったプロセス間通信をする方法の紹介です。

Rubyから外部のプログラムを起動して、標準入力からデータを入力し、 標準出力から結果を取り出したいという場合には、 IO.popenを使うと便利です。使い方は以下のとおり。

   1  IO.popen('/usr/bin/command', 'r+') do |io|
   2    io.puts "something to input"
   3    @result = io.gets
   4  end

See Also

posted by Png genki on Fri 14 Mar 2008 at 18:38

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry451
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ