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
22
votes
2 answers

How to avoid the 'tlsv1 alert unknown ca' error in libmproxy?

Currently using libmproxy, which in turn uses telnetlib, to make requests to HTTPS Web pages. However, the following error is raised: Error: [('SSL routines', 'SSL3_READ_BYTES', 'tlsv1 alert unknown ca')] I believe this is related to the inability…
Juan Carlos Coto
  • 11,900
  • 22
  • 62
  • 102
17
votes
7 answers

telnetlib python example

So I'm trying this really simple example given by the python docs: import getpass import sys import telnetlib HOST = "" user = raw_input("Enter your remote account: ") password = getpass.getpass() tn =…
de1337ed
  • 3,113
  • 12
  • 37
  • 55
12
votes
1 answer

Python - Remove Last Line From String

I'm trying to capture and manipulate data within a Telnet session using telnetlib, things are going fairly well, however my newbness with Python is causing me some headache. My issue is pretty straight forward, I am able to capture and display the…
user2735454
  • 335
  • 1
  • 5
  • 14
9
votes
3 answers

Reading output with telnetlib in realtime

I'm using Python's telnetlib to telnet to some machine and executing few commands and I want to get the output of these commands. So, what the current scenario is - tn = telnetlib.Telnet(HOST) tn.read_until("login: ") tn.write(user + "\n") if…
theharshest
  • 7,767
  • 11
  • 41
  • 51
6
votes
2 answers

How to print telnet response line by line?

Is it possible to print the telnet response line by line, when a command executed over telnet keeps on responding over console ? Example: I have executed a command (to collect logs), It keeps on displaying logs on console window. Can we read the…
Jackie James
  • 785
  • 8
  • 15
  • 28
5
votes
3 answers

Anyone had luck with telnetlib.expect()?

I'm writing a library to support telnet'ing to a remote server and running apps. Things are going swimmingly in establishing a connection, getting data back, parsing, etc. (at least as swimmingly as it can be for communicating with programs via a…
JS.
  • 14,781
  • 13
  • 63
  • 75
5
votes
0 answers

How to use proxy with telnetlib

Hello recently I started working with telnetlib and now I need to route it through a proxy. I asked myself if there is a way to do that since you can also use proxies with requests.get(proxies=) for example?
Bluescream
  • 261
  • 1
  • 8
5
votes
1 answer

How to check if Telnet connection is still established? using telnetlib

I'd like to check if a connection using the telnetlib is still up. The way I do it is to send a ls command and check the answer, but I'm sure there must be a smoother solution.
r00flr00fl
  • 318
  • 6
  • 16
4
votes
4 answers

Detect a closed connection in python's telnetlib

I'm using python's telnetlib to connect to a remote telnet server. I'm having a hard time detecting if the connection is still open, or if the remote server closed it on me. I will notice the connection is closed the next time I try to read or write…
zigdon
  • 14,573
  • 6
  • 35
  • 54
4
votes
1 answer

How to include regular expression in tn.read_until()?

import telnetlib tn = telnetlib.Telnet(IP) tn.read_until("abcd login: ") --> This is only to match a particular pattern Can a generic pattern be included in tn.read_until() ? Ex: prompt can be "xyz login: " , "abcd login: " etc In regular…
Jackie James
  • 785
  • 8
  • 15
  • 28
4
votes
1 answer

Unit testing pythons telnetlib

I'm writing a simple program that talks to a router via telnet and issues some simple commands to it. I want to be able to test these commands, that the program responds correctly to the servers output and sends the commands at the right moments.…
grimurd
  • 2,750
  • 1
  • 24
  • 39
4
votes
2 answers

How do I send telnetlib control + c command in python

I am trying to send control + c command in python using telnetlib library. Currently I am doing tn.write('^]') But the code above doesn't seem to work. Any clue on What I should use?
Dhruv Patel
  • 426
  • 3
  • 9
  • 19
4
votes
2 answers

Python Telnetlib read_until '#' or '>', multiple string determination?

if (tn.read_until('>')): action1 else: action2 or if (tn.read_until() == '>'): action1 else: action2 I just want the read_until() to check which desired String comes first, and do different actions. Or is there any equivalent ways?
user3352539
  • 79
  • 1
  • 1
  • 8
4
votes
2 answers

Accessing a telnet session in python

so I need to access a telnet session. More specifically JPL's ephemeris service. I know exactly what I need to do in the command prompt, but I've had trouble using the telnetlib package. Here are the steps I need to take through command…
4
votes
1 answer

Python multiple telnet sessions

I need to build a script to get the telnet output of as many hosts as possible and save them to a separate file for each host. The script should run as a daemon. For the moment i have a function that encapsulates the logic for do it for a single…
danidelvalle
  • 146
  • 1
  • 7
1
2 3
21 22