Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- ssh=paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect('hostname', port=22, username= 'xxxxx', password='yyyy')
- stdin, stdout, stderr = ssh.exec_command('sh ip int brief')
- output = stdout.read()
- print "n".join(output)
- import smtplib
- sender = 'xxxx@gmail.com'
- receivers = ['yyy@gmail.com','zzz@gmail.com']
- body = "n" + output + "n"
- message = """From: From Person <xxxx@gmail.com>
- To: To Person <yyy@gmail.com>
- Subject: SMTP e-mail test
- This is a test e-mail message from jay.
- """
- try:
- smtpObj = smtplib.SMTP('smtp.com')
- smtpObj.sendmail(sender, receivers, message)
- print "Successfully sent email"
- except Exception:
- print "Error: unable to send email"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement