Third, Python, filename: autotelnet.py, code: #!/usr/bin/pyton importtelnetlib host = ' ' 10.32.17.10 ' ' user = ' root ' password = ' ' 123456 '' commands = [' en ', ' password ', ' conft ' ', ' ' intfa0/1 ', ' ' switchportmodemulti ' ', ' ' end ' '] tn = telnetlib.Telnet (host) tn.read_until ("Username:") tn.write (user + "n") tn.read_until ("Password:") tn.write (password + "n") forcommandincommands: tn.write (command + '' n '') tn.write ("exitn") printtn.read_all () print''Finis! ''
No comments:
Post a Comment