Path: blob/master/lib/rex/ui/text/output/tee.rb
19715 views
# -*- coding: binary -*-12module Rex3module Ui4module Text56###7#8# This class implements output against a file and stdout9#10###11class Output::Tee < Rex::Ui::Text::Output1213attr_accessor :fd1415def initialize(path)16self.fd = ::File.open(path, "ab")17super()18end1920def supports_color?21case config[:color]22when true23return true24when false25return false26else # auto27term = Rex::Compat.getenv('TERM')28return (term and term.match(/(?:vt10[03]|xterm(?:-color)?|linux|screen|rxvt)/i) != nil)29end30end3132#33# Prints the supplied message to file output.34#35def print_raw(msg = '')36$stdout.print(msg)37$stdout.flush3839return if not self.fd40self.fd.write(msg)41self.fd.flush42msg43end4445alias :write :print_raw4647def close48self.fd.close if self.fd49self.fd = nil50end51end5253end54end55end56575859