module Rex
module Ui
module Text
class Output::Tee < Rex::Ui::Text::Output
attr_accessor :fd
def initialize(path)
self.fd = ::File.open(path, "ab")
super()
end
def supports_color?
case config[:color]
when true
return true
when false
return false
else
term = Rex::Compat.getenv('TERM')
return (term and term.match(/(?:vt10[03]|xterm(?:-color)?|linux|screen|rxvt)/i) != nil)
end
end
def print_raw(msg = '')
$stdout.print(msg)
$stdout.flush
return if not self.fd
self.fd.write(msg)
self.fd.flush
msg
end
alias :write :print_raw
def close
self.fd.close if self.fd
self.fd = nil
end
end
end
end
end