'Helper function for run().'

def _run(self, command, timeout, ignore_status, stdout, stderr, connect_timeout, env, options, stdin, args):

    ssh_cmd = self.ssh_command(connect_timeout, options)
    if (not env.strip()):
        env = ''
    else:
        env = ('export    %s;' % env)
    for arg in args:
        command += ('    "%s"' % utils.sh_escape(arg))
    full_cmd = ('%s    "%s    %s"' % (ssh_cmd, env, utils.sh_escape(command)))
    result = utils.run(full_cmd, timeout, True, stdout, stderr, verbose=False, stdin=stdin, stderr_is_expected=ignore_status)
    if (result.exit_status == 255):
        if re.search('^ssh:    connect    to    host    .*    port    .*:    Connection    timed    out\\r$', result.stderr):
            raise error.AutoservSSHTimeout('ssh    timed    out', result)
        if ('Permission    denied.' in result.stderr):
            msg = 'ssh    permission    denied'
            raise error.AutoservSshPermissionDeniedError(msg, result)
    if ((not ignore_status) and (result.exit_status > 0)):
        raise error.AutoservRunError('command    execution    error', result)
    return result
