青山です。
せっかく分割ログが取れるようになったので、もう少し実用的に変更しました。
in.coming に入れて置きましたので、よろしくお願い致します。
forum_read, patio_read 等の返す値にはメッセージやプロンプトは含まれず、
発言のみとなります。次のような感じできれいに分割されるので、ログカッタ
で悩む必要がなくなります。(イテレータ形式でのリアルタイム出力にはプロ
ンプト等もすべてそのまま渡されます)
#!/usr/local/bin/ruby -Ke
require "nif.rb"
def open_log(log_name, &block)
file = File.open(log_name, "a")
file.sync = true
block.call(file)
file.close
end
nif = Nifty.new({'id' => 'ID',
'password' => 'PASSWORD',
'log' => Time.now.strftime("%Y%m%d.all") })
STDOUT.sync = true
open_log(Time.now.strftime("%Y%m%d.nif")){|log|
log.print nif.login{|c| STDOUT.print c }
}
open_log(Time.now.strftime("%Y%m%d.ts")){|log|
log.print nif.forum_read("FGALTS", "ALL"){|c| STDOUT.print c }
}
open_log(Time.now.strftime("%Y%m%d.nif")){|log|
log.print nif.logout{|c| STDOUT.print c }
}
--
青山 和光 Wakou Aoyama <wakou / fsinet.or.jp>