I am trying to use telnet to check service connections to a server. This is the code I used:
p = subprocess.run("telnet localhost 80", shell=True, universal_newlines=True, stdout=subprocess.PIPE)
print(p.stdout)
if I run this there is a blank response and it seems telnet is waiting to timeout in the background until I press ctrl+c
.
If I run the following code:
p = subprocess.run("telnet localhost 80", shell=True, universal_newlines=True)
there is a response as below:
Trying ::1...
Connected to localhost.
Escape character is '^]'.
If I want to use this script to test connections to servers, how do pass ctrl+]
and 'quit' to get out of the telnet prompt?
Also, if I want to test responses using "GET/" to telnet, how do I do it ?