Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import getpass
- import re
- import telnetlib
- HOST = "ip of host"
- user = raw_input("Enter your remote account: ")
- password = raw_input("Enter the password: ")
- tn = telnetlib.Telnet(HOST)
- tn.read_until("login: ")
- tn.write(user + "n")
- tn.read_until("Password: ")
- tn.write(password + "n")
- tn.read_until("*>")
- tn.write("command-to-be-executedn")
- tn.write("exitn")
- output = tn.read_all()
- f= open("C:/Python27/Scripts/logfile/module_show.txt" , "w+")
- f.write(output)
- f.close()
- tn.close()
- import re
- regex = re.compile("^(|ER)")
- with open("C:/Python27/Scripts/logfile/module_show.txt") as f:
- for line in f:
- result = regex.search(line)
- if result:
- print line
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement