Questions tagged [telnetlib]

The telnetlib module provides a Telnet class that implements the Telnet protocol under Python programming language.

The telnetlib module provides a Telnet class that implements the Telnet protocol under Python programming language.

See RFC 854 for details about the Telnet protocol.

In addition, telnetlib provides symbolic constants for the protocol characters (see below), and for the telnet options. The symbolic names of the telnet options follow the definitions in arpa/telnet.h, with the leading TELOPT_ removed. For symbolic names of options which are traditionally not included in arpa/telnet.h, see the module source itself.

Read more about telnetlib at python docs..

318 questions
2
votes
2 answers

Telnet works for localhost however not for the raw IP address

I'm running a socket on my Mac laptop and when I telnet the IP address of my computer it says (IP is hidden for security reasons): telnet 7-.---.--.--- 4005 Trying 7-.---.--.---... telnet: connect to address 7-.---.--.---: Connection refused …
Akhil Reddy
  • 257
  • 7
  • 17
2
votes
1 answer

Writing telnetlib's Telnet.interact() stream to file

I need to establish a connection to a telnet server which continually broadcasts information and save all of that information to a file. For testing, I am using the famous ASCII Star Wars located on towel.blinkenlights.nl In essence, I need to…
2
votes
0 answers

Exscript: Telnet response includes prompt's first character?

I need to use "telnet" to connect to my camera. I had used putty and knew that the camera prompt was '~ # '. If I execute 'echo "test"' then I expect the response 'echo "test"\r\ntest\r\n'. But Exscript's response is 'echo "test"\r\ntest\r\n~',…
2
votes
2 answers

"Snooping" python's telnetlib

I have an application that calls telnetlib.read_until(). For the most part, it works fine. However when my app's telnet connection fails, it's hard to debug the exact cause. Is it my script or is the server connection dodgy? (This is a development…
JS.
  • 14,781
  • 13
  • 63
  • 75
2
votes
1 answer

Telnetlib, bytestrings, and "invalid escape sequence"

I'm using telnetlib.expect() to interface with a device that responds in bytestrings, apparently. Unless I use bytestrings in the regex passed to expect() (either precompiled, or literals), an exception is generated: TypeError: cannot use a string…
Quantum Mechanic
  • 625
  • 1
  • 6
  • 20
2
votes
2 answers

Send telnet command in python

I'm trying to send command in tetnet but it's not working. i tried different code find in this forum but no one works. it's for rebooting a device. i'm using python 3.6. import telnetlib host = "192.168.1.0" port = 23 timeout = 100 session =…
Micky
  • 1,295
  • 3
  • 8
  • 5
2
votes
2 answers

How can i get telnet output printed line by line?

I have implemented a script that connects to a Cisco device and collects the show run output. The script is: import getpass import telnetlib import time HOST = "10.62.149.9" user = input("Enter your remote account: ") password =…
AlexCCIE
  • 51
  • 1
  • 5
2
votes
0 answers

telnetlib hangs when run on command line

I am trying to create a shutdown script to remotely power down some servers remotely; I have enabled telnet, and when using PuTTY or similar, it is a simple matter to run the shutdown procedure. I attempted to automate using the following Python…
2
votes
1 answer

Delay when setting label text via button click in PyQt5 interface

I want to connect to a telnet device with a button click (PyQt5 interface). Upon pressing the 'Connect' button, the label should change to 'connecting'. The same label should change to 'connected' when a connection is established. It usually takes a…
blitz
  • 623
  • 5
  • 18
2
votes
4 answers

python3 telnet read_all() doesn't work

I am telneting to a Cisco router via Python3. However, it hangs up after running the script (But I am able to telnet to the router from my Linux bash). Please see the snippets of my script and outputs below. import getpass import telnetlib HOST =…
Jones Doe
  • 51
  • 1
  • 6
2
votes
0 answers

telnetlib python read_all() not getting any output (hangs)

I am trying to telnet into the cisco console server on a given line with my python script using telnetlib Below I have mention my code: import time import getpass import sys import telnetlib HOST = "172.30.144.182" user = raw_input("enter the…
User_1
  • 21
  • 3
2
votes
1 answer

What debug levels are available for telnetlib?

What do the debug level numbers correspond to in python's telnetlib? What is the maximum debug level? I've set numbers up to 400 without causing an exception. https://docs.python.org/2/library/telnetlib.html#telnetlib.Telnet.set_debuglevel
tarabyte
  • 17,837
  • 15
  • 76
  • 117
2
votes
0 answers

Python telnetlib try/catch issues

Can someone help me how to fix the code below? Been using the code below for telnet connection. Why is it that the exception will still be executed after try statement? Dialog still displayed, even if timeout number increases. try: tn =…
2
votes
1 answer

Reading live output from telnet connection in python

I have an Arduino set up as a server. In Terminal (I use a Mac), one can connect to it, see the output, and close the connection as follows: > telnet HOST Trying 192.168.0.101... Connected to HOST. Escape character is '^]'. 0 , 25486 , 0.00 : 1 ,…
Nick C
  • 73
  • 1
  • 8
2
votes
2 answers

Python telnetlib read_until returns cut off string

[Python telnetlib read_until recv problem] "read_until" function returns cut off string with long commands. The commands ran perfectly, but it does not show full texts. How can I fix this? Please help. # my code tn = telnetlib.Telnet(ip, 23,…
curtis
  • 23
  • 1
  • 5
1 2
3
21 22