Jan-21-2021, 06:49 PM
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.
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'))