Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- To Explain: Any ******* is to blank out sensitive information, the actual script has the actual information in it.
- All Checkpoint lines I added to debug a hangup in the program earlier on.
- This program works but I want to be able to see the router's output with each command issued.
- 1 import getpass
- 2 import sys
- 3 import telnetlib
- 4
- 5 HOST = "*******************"
- 6 # Another way to do this is: user = raw_input("Enter your user name: ")
- 7 user = raw_input("User Name: ")
- 8 # print "Checkpoint Line 8 Past UserName Input"
- 9 # user = "*********"
- 10 # Another way to do this is: password = getpass.getpass()
- 11 password = getpass.getpass()
- 12 # print "Checkpoint Line 12 Past Password Input"
- 13 # password = "***********************"
- 14
- 15 tn = telnetlib.Telnet(HOST)
- 16 # print "Checkpoint Line 16 Past Obj Creation and Connection Opening"
- 17 tn.read_until("login: ")
- 18 # print "CheckPoint Line 18 Past Read Until Login"
- 19 tn.write(user + "\n")
- 20 # print "Checkpoint Line 20 Past Write Username and CR"
- 21 tn.read_until("Password: ")
- 22 # print "Checkpoint Line 22 Past Read Until Password"
- 23 tn.write(password + "\n")
- 24 # print "Checkpoint Line 24 Past Write Password and CR"
- 25 tn.read_until("5308> ")
- 26 # print "Checkpoint Line 26 Past Read until 5308"
- 27 # tn.write("show net lan dhcp reserved_ip setup\n")
- 28 tn.write("security firewall ipv4 enable 20\n")
- 29 # print tn.read_all()
- 30 # print "Checkpoint Line 28 Past Show Reserved IP Info"
- 31 tn.read_until("5308> ")
- 32 # print "Checkpoint Line 30 Past Read Until 5308"
- 33 tn.write(".exit\n")
- 34 # print "Checkpoint Line 32 Past Write Exit"
- 35
- 36 print tn.read_all()
- 37 #print "Checkpoint Line 35 End Of Program"
Add Comment
Please, Sign In to add comment