Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Connect(self, hostinfo, userinfo):
- self.client = paramiko.SSHClient()
- self.client.load_system_host_keys()
- self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- self.client.connect(hostinfo["ip"], hostinfo["port"], userinfo["username"], userinfo["password"])
- self.channel = self.client.invoke_shell()
- self.channel.settimeout(2)
- def Send(self, cmd="", end=""):
- self.channel.send(''.join([cmd, 'n']))
- return self.Receive(end)
- def Receive(self, end=""):
- re_ = re.compile(end)
- data = ""
- while True:
- temp = ""
- print(1111)
- # time.sleep(0.5)
- if self.channel.recv_ready():
- try:
- temp = self.channel.recv(65535).replace(b"rn", b"n").decode("GB18030")
- except socket.timeout:
- return data
- data = "".join([data, temp])
- if re_.search(data):
- return data
Add Comment
Please, Sign In to add comment