Aug-10-2019, 09:52 AM
Trying to get data (mainly temperature) from a UniFi Switch 16 POE-150W.
Have to first enter the switch with ssh, then telnet into the local host, then issue a "show env" command.
I am having problems getting a return of data after the telnet command. Here's how far I got:
Have to first enter the switch with ssh, then telnet into the local host, then issue a "show env" command.
I am having problems getting a return of data after the telnet command. Here's how far I got:
##first install pexpect .. pip install pexpect from pexpect import pxssh import getpass import time import sys import subprocess try: s = pxssh.pxssh() hostname = '192.168.1.7' username = 'u-name' password = 'p-word' s.login(hostname, username, password) #just to prove we are logged into ssh tunnel s.sendline('ls') s.prompt() print(s.before) # telnet into the switch s.sendline('telnet localhost') time.sleep(.5) # just wait a bit print(sys.stdout) #does not work # for line in sys.stdout: # print(line) #this is the command to get temperature and other data s.sendline('show env\n') print(sys.stdout) s.logout() except pxssh.ExceptionPxssh as e: print("pxssh failed on login.") print(e)