Telnet Switch And Shutdown Port - Python
In this Example is going to shutdown and no shutdown on port: FastEthernet0/1
SHUTDOWN
#!/usr/bin/python
import getpass
import sys
import telnetlib
HOST =
"123.123.123.155"
user =
raw_input("Enter your remote account: ")
password =
getpass.getpass()
telnet =
telnetlib.Telnet(HOST)
telnet.read_until("username:
",3)
telnet.write(user +
"\n")
if password:
telnet.read_until("password:",3)
telnet.write(password + "\n")
telnet.write("show
ip int br\n")
telnet.write("configure
terminal\n")
telnet.write("interface
FastEthernet0/1\n")
telnet.write("shutdown\n")
telnet.write("end\n")
telnet.write("wr\n")
telnet.write("exit\n")
print "######
ALL COMMAND RUNNING #####"
print
telnet.read_all()
NO SHUTDOWN
#!/usr/bin/python
import getpass
import sys
import telnetlib
HOST =
"123.123.123.155"
user =
raw_input("Enter your remote account: ")
password =
getpass.getpass()
telnet =
telnetlib.Telnet(HOST)
telnet.read_until("username:
",3)
telnet.write(user +
"\n")
if password:
telnet.read_until("password:",3)
telnet.write(password + "\n")
telnet.write("show
ip int br\n")
telnet.write("configure
terminal\n")
telnet.write("interface
FastEthernet0/1\n")
telnet.write("no
shutdown\n")
telnet.write("end\n")
telnet.write("wr\n")
telnet.write("exit\n")
print "######
ALL COMMAND RUNNING #####"
print
telnet.read_all()
No comments:
Post a Comment