def execute(self, command, timeout=None):
try:<EOL><INDENT>self.channel = self.ssh.get_transport().open_session()<EOL><DEDENT>except paramiko.SSHException as e:<EOL><INDENT>self.unknown("<STR_LIT>" % e)<EOL><DEDENT>try:<EOL><INDENT>self.channel.settimeout(self.args.timeout if not timeout else timeout)<EOL><DEDENT>except socket.timeout as e:<EOL><INDENT>self.unknown("<STR_LIT>" % e)<EOL><DEDENT>try:<EOL><INDENT>self.logger.debug("<STR_LIT>".format(command))<EOL>self.channel.exec_command(command)<EOL><DEDENT>except paramiko.SSHException as e:<EOL><INDENT>self.unknown("<STR_LIT>" % e)<EOL><DEDENT>try:<EOL><INDENT>self.stdin = self.channel.makefile('<STR_LIT:wb>', -<NUM_LIT:1>)<EOL>self.stderr = map(string.strip, self.channel.makefile_stderr('<STR_LIT:rb>', -<NUM_LIT:1>).readlines())<EOL>self.stdout = map(string.strip, self.channel.makefile('<STR_LIT:rb>', -<NUM_LIT:1>).readlines())<EOL><DEDENT>except Exception as e:<EOL><INDENT>self.unknown("<STR_LIT>" % e)<EOL><DEDENT>try:<EOL><INDENT>self.status = self.channel.recv_exit_status()<EOL><DEDENT>except paramiko.SSHException as e:<EOL><INDENT>self.unknown("<STR_LIT>" % e)<EOL><DEDENT>else:<EOL><INDENT>if self.status != <NUM_LIT:0>:<EOL><INDENT>self.unknown("<STR_LIT>" % (self.status, self.errors))<EOL><DEDENT>else:<EOL><INDENT>return self.stdout<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>self.logger.debug("<STR_LIT>")<EOL><DEDENT>
Execute a shell command.