コード例 #1
0
ファイル: easytel.py プロジェクト: Cushychicken/easytel
class Easytel:
    def __init__(self, host, login, password, expect):
        """
            Class constructor
            
            *host = name/IP of target machine
            *login = login ID of target machine
            *password = password for login ID of target machine
            *expect = prompt character for telnetlib class to expect
        """
        self.telnet = TelnetController(host, login, password, expect)
        self.telnet.login()
        
    def talk(self, command):
        """
            Function that relays commands to telnet machine. 
            
            *command = string or list of strings of commands for host machine to run
            
            Returns list of tuples where 
                * t[0] = command run
                * t[1] = console output from command
        """
        if type(command) is not list: command = [ command ]
        
        history = []
        for cmd in command:
            history.append((cmd, self.telnet.run_command(cmd)))
        return history
        
    def hangup(self):
        self.telnet.logout()
コード例 #2
0
ファイル: easytel.py プロジェクト: Cushychicken/easytel
 def __init__(self, host, login, password, expect):
     """
         Class constructor
         
         *host = name/IP of target machine
         *login = login ID of target machine
         *password = password for login ID of target machine
         *expect = prompt character for telnetlib class to expect
     """
     self.telnet = TelnetController(host, login, password, expect)
     self.telnet.login()