Powerball number picker

So I spent a little time the other day applying what little I know of Python to the concept of picking Powerball lottery numbers because I had nothing much else to do that the time.  In the interest of not only content put putting more of my terrible code out there for people to laugh at I present my simple powerball picker script.

#!/usr/bin/python
from array import *
from random import *
num = array('i')

def create_array():

        for i in range(0,59):
                ins = i + 1
                num.insert(i, ins)
        return num
def pick_a_number():
        your_number = ''
        for n in range(1,6):
                ca = create_array()
                pick = randrange(0,len(ca))
                your_number += str(ca[pick])
                your_number += '  '
                # now we exclude the number
                num.pop(pick)
        print "Your Picks >> "+your_number+" Powerball: "+str(randrange(1,36))

start = 1;
stop = int(raw_input("How many picks would you like to generate? "))

for p in range(start, stop+1):
        pick_a_number()

* note – if you win a huge jackpot with numbers from this send a few bills my way!

Account Info Script

Had to do a quick crontab job at work to grab user details out of /etc/passwd and email the details in a report, here is the resulting script

#!/bin/bash
> account-report.txt
date > account-report.txt
echo -e "=== Account Report ===n" >> account-report.txt
Nlist=${1:-nodelist.txt}
hName=( $(awk '{print $1}' $Nlist) );
for name in "${hName[@]}"; do

        users=$(cat <<EOL
                cat /etc/passwd | grep "/bin/bash" | grep "[1-9][0-9][0-9]" | cut -d: --fields=1,5

EOL
)
        echo "Host: $name" >> account-report.txt
        ssh -o StrictHostKeyChecking=no ${name} "$users" >> account-report.txt
        echo -e "End of $name accountsnn" >> account-report.txt
done

mailx -s "Monthly Account Report" user@host.tld < account-report.txt

It grabs a list of hostnames from nodelist.txt and utilizes a ssh key-trust to connect to the hosts without supplying a password.  We lucked out bigtime that there was a trust already setup otherwise the whole process would have been overly complicated requesting permission to setup a trust in the first place.

Close Bitnami banner
Bitnami