I have a background in Unix / Linux system administration and as such, I have a lot of experience with bash script programming. Lately I've been moving away from bash scripting and playing more with python.

Though some tasks are better suited for bash scripting, a lot of them are easier and simpler when done with a python script. In this section, I will add sample scripts that I've written from scratch or have put together from other sources. I hope they will be useful to you.

#!/usr/bin/env python
# Generate random strings that can be used for login passwords
# These 2 functions do the exact same thing, it's just a different
# way of doing it to show python's versatility

import string
from random import choice

def GenPasswd1(len):
passwd = ''
chars = string.letters + string.digits
for i in range(len):
passwd = passwd + choice(chars)
return passwd

def GenPasswd2(length, chars):
return ''.join([choice(chars) for i in range(length)])

passone = GenPasswd1(8)
passtwo = GenPasswd2(12, string.letters + string.digits)

print "Random strings for passwords:\n"
print " 8 chars long: %s" % passone
print "12 chars long: %s" % passtwo