from telnetlib import Telnet myinterface = input('What Interface would you like to configure [E0/0,Loopback200 etc]:') Ipaddr = input('Specify the IP Address : ') SMask = input('Specify the Subnet mask : ') ab = Telnet('172.25.1.1') ab.write(b'khawar\n') ab.write(b'cisco\n') ab.write(b'config t\n') int_cmd='Interface ' + myinterface + '\n' ipaddr_cmd ='ip address ' + Ipaddr + ' ' + SMask + '\n' ab.write(int_cmd.encode('ascii')) ab.write(ipaddr_cmd.encode('ascii')) ab.write(b'no shut\n') ab.write(b'end\n') ab.write(b'sh ip int brief\n') ab.write(b'exit\n') print (ab.read_all().decode('ascii')) input('Press ENTER to Continue')