def run_cmd(cmd, output_object=nil)
    # This implementation is taken from Meterpreter.
    stored_output_state = nil
    # If the user supplied an Output IO object, then we tell
    # the console to use that, while saving it's previous output/