#!/bin/sh #Author Paul Sims #This does some fun password generation, it's ez so no explanation needed. #Set this to your random device: RANDOMDEV=/dev/urandom #This function does all the work function generar { dd if=$RANDOMDEV count=1 2>/dev/null | uuencode -m -| head -n -2 | tail -n 1 | cut -c-$LENGTH } function help_menu { cat << EOF Usage: (-n Number of passwords | -l Length of passwords) Example: $0 -n 5 -l 8 That will generate 5 passwords with 8 characters each. EOF exit 0 } #Grab the options while getopts n:l:h X do case "$X" in n) NUMBER=$OPTARG ;; l) LENGTH=$OPTARG ;; h) help_menu ;; esac done #pebkac tests if [ -z $NUMBER ] then echo "You must tell me how many passwords to generate. Use -h for more info." exit 1 fi if [ -z $LENGTH ] then echo "You must tell me how many digits are in the passwords to generate. Use -h for more info." exit 1 fi #Here's the actual work for ((n=0;n<$NUMBER;n++)); do generar ; done