Working on my first python script at work to automate some testing.
I'm having trouble telneting to a server twice from my script. The first time I'm calling the telnet function, everything works, the second time my script calls the telnet function, I get the following errors below. I have a second function that runs some commands and exits. I've also tried without an exit, but that did not work either. So I thought that would close out the session, by doing a "close" on the session as well.
Thanks in advance.
The reason I want to go back into the server, is I make a change to the DB and want to verify the change took affect.
I'm calling these functions from another python script.
** Updated with where "tn" is assigned, which is outside the function, so I'm unsure how telnet even works the first time.
tn = telnetlib.Telnet(intems03, "8123")
def telnet_ems():
tn.read_until(b"Login :")
tn.write(bytes(username + "\n", "UTF-8"))
tn.read_until(b"Password:")
tn.write(bytes(password + "\n", "UTF-8"))
def show_sip_domain(sipDomain):
str2byte = sipDomain.encode("ascii")
tn.write(b"show Sip_Domain Sip_Domain_Id "+str2byte)
tn.write(b"\n")
tn.write(b"exit\n")
** Error messages **
Traceback (most recent call last):
File "c:\Users\xxxx\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\ptvsd_launcher.py", line 43, in <module> main(ptvsdArgs)
File "c:\Users\xxxx\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main run()
File "c:\Users\xxxx\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file runpy.run_path(target, run_name='__main__')
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 263, in run_path pkg_name=pkg_name, script_name=fname)
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 96, in _run_module_code mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "c:\Python_Exercises\Selenium_test_examples\test_TelnetEms.py", line 11, in <module> telnet_ems()
File "c:\Python_Exercises\Selenium_test_examples\Telnet_EMS_Show_functions.py", line 16, in telnet_ems tn.read_until(b"Login :")
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37-32\lib\telnetlib.py", line 315, in read_until self.fill_rawq()
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python37-32\lib\telnetlib.py", line 524, in fill_rawq buf = self.sock.recv(50)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine