Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getpass.getpass error
#1
Hey guys I'm getting this error when trying to run my code. Anyway someone could help me out. Thanks!
Bellow is the command line trying to run the run the code, and under that is the actual code.



Error:
root@NetworkAutomation-1:~# python3 getpass.py Enter your telnet username: tasha Traceback (most recent call last): File "getpass.py", line 3, in <module> import getpass File "/root/getpass.py", line 8, in <module> password = getpass.getpass() TypeError: 'module' object is not callable
import getpass
import telnetlib

HOST = "192.168.122.71"
user = input("Enter your telnet username: ")
password = getpass.getpass()

tn = telnetlib.Telnet(HOST)

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

tn.write(b"enable\n")
tn.write(b"mouse\n")
tn.write(b"conf t\n")
tn.write(b"int loop 0\n")
tn.write(b"ip address 1.1.1.1 255.255.255.255\n")
tn.write(b"end\n")
tn.write(b"exit\n")

print(tn.read_all().decode('ascii'))
buran write Jan-21-2021, 06:51 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.

Also, always post in the correct forum. This time I moved your thread.
Reply


Messages In This Thread
getpass.getpass error - by Juice1277 - Jan-21-2021, 06:49 PM
RE: getpass.getpass error - by buran - Jan-21-2021, 06:52 PM
RE: getpass.getpass error - by Juice1277 - Jan-21-2021, 09:51 PM
RE: getpass.getpass error - by Juice1277 - Jan-21-2021, 10:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 946 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  getpass ComputerAstronaut 1 1,653 Nov-16-2020, 01:16 AM
Last Post: bowlofred
  Error "an integer is required" in getpass.getuser(). Nirelg 5 5,578 Mar-20-2017, 04:19 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020