Monthly Archives: December 2012
Command Line Wifi
Find the available wireless interface: iwconfig Scan Wireless networks iwlist wlan0 scan “wlan0 is the wireless interface” Connect wifi with… Continue reading »
Python Easy Backup Monitor
This setup contains 3 files. log.py this script will send a reminer everyweek that the backup must be changed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
#Gebruikte LIBS from datetime import * import os, time import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText # Variable first = "" second = "" third = "" fourth = "" fifth = "" sender = 'SAPSERVER' #sender Name path = 'Z:\\backup_files\\' # path where the backup files are stored today=datetime.date(datetime.now()) week_nr=today.strftime("%U") backup2 = ["01","03","05","07","09","11","13","15","17","19","21","23","25","27","29","31","33","35","37","39","41","43","45","47","49","51"] backup1 = ["02","04","06","08","10","12","14","16","18","20","22","24","26","28","30","32","34","36","38","40","42","44","46","48","50",'52'] #Functies def backup_check(nr): for word in backup1: if word == nr: return "backup1" for word in backup2: if word == nr: return "backup2" #Log Body log = open("backup.log","w") log.write("<h2>Vergeet vandaag niet om "+(backup_check(week_nr))+" te plaatsen</h2>") log.write("<h3>***********************BACK-UP logboek:************************</h3>") dirEntries = os.listdir(path) log.write("<table border='1' style='text-align: center;'>") log.write("<tr>") log.write("<th> Backup name </th>") log.write("<th> last modified </th>") log.write("<th> Backup size GB </th>") log.write("<th> Backup size MB </th>") log.write("</tr>") for entry in dirEntries: (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(path+entry) log.write("<tr>") log.write("<td>"+entry+"</td>") log.write(("<td>"+time.ctime(mtime))+"</td>") log.write("<td>"+str((size / (1<<30)))+" GB"+"</td>") log.write("<td>"+str((size / (1<<20)))+" MB"+"</td>") log.write("</tr>") log.write("</table>") log.write("<h3>*****************************************************************</h3>") log.close() # Mailing msg = MIMEMultipart() msg['From'] = sender msg['To'] = receivers msg['Subject'] = "Vergeet vandaag niet om "+(backup_check(week_nr))+" te plaatsen" html1 = open('backup.log',"r") part1 = MIMEText(html1.read(), 'html') msg.attach(part1) html1.close() try: smtpObj = smtplib.SMTP('192.168.3.1') #Replace this IP adres with your SMTP smtpObj.sendmail(sender, receivers, msg.as_string()) print "Successfully sent email" except Exception: print "Error: unable to send email" |
Openrelay Test
This website contains one of the best SMTP Open relay tests. http://www.test-smtp.com
Debian Static Ip IPv4 and IPv6
This is an example of how you can configure IPv4 and IPv6 static ip-addresses in Debian. nano /etc/network/interfaces
1 2 3 4 5 6 7 |
auto eth0 iface eth0 inet static address 192.168.3.10 netmask 255.255.255.0 network 192.168.3.0 broadcast 192.168.3.255 gateway 192.168.3.1 |
1 2 3 4 |
iface eth0 inet6 static address fd4e:a32c:3873:9e59:0004::254 gateway fd4e:a32c:3873:9e59:0004::1 netmask 80 |
Python SMTP client/server example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import smtplib import email.utils from email.mime.text import MIMEText # Create the message msg = MIMEText('This is the body of the message.') msg['Subject'] = 'Simple test message' server = smtplib.SMTP('127.0.0.1', 1025) server.set_debuglevel(True) # show communication with the server try: finally: server.quit() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import smtpd import asyncore class CustomSMTPServer(smtpd.SMTPServer): def process_message(self, peer, mailfrom, rcpttos, data): print 'Receiving message from:', peer print 'Message addressed from:', mailfrom print 'Message addressed to :', rcpttos print 'Message length :', len(data) return server = smtpd.PureProxy(('127.0.0.1', 1025), ('mail', 25)) print 'Server is gestart' asyncore.loop() |