Answers for "tn.read_until(b"Username: ", 3)"

0

tn.read_until(b"Username: ", 3)

import getpass
import telnetlib

HOST = "localhost"
user = input("Enter your remote account: ")
password = getpass.getpass()

tn = telnetlib.Telnet(HOST)

tn.read_until(b"login: ")
tn.write(user.encode('ascii') + b"\n")
if password:
    tn.read_until(b"Password: ")
    tn.write(password.encode('ascii') + b"\n")

tn.write(b"ls\n")
tn.write(b"exit\n")

print(tn.read_all().decode('ascii'))
Posted by: Guest on November-04-2020

Code answers related to "tn.read_until(b"Username: ", 3)"

Python Answers by Framework

Browse Popular Code Answers by Language