Tech Support > Operating Systems > UNIX / Variants > Google Groups suggested this group to me. Go figure.
Google Groups suggested this group to me. Go figure.
Posted by humbubba on October 12th, 2006


Here's a fun little challenge for unix admins....


source this file into the shell state, then execute test functions,
# then votescript.

echo "
votescript. Paper ballots, happy electronic trails.

This is an example program that makes a PC and printer a ballot editing

station for elections with paper ballots.

This is maybe the all-time example of the K.I.S.S. rule, Keep It Simple

Stupid. Most of this can be customized to a particular locality with
almost no knowledge of programming. I hope.

Rick Hohensee, April 2004 & Sept/Oct. 2006
GNU Bash shell script, probably a trivial port to BSD, MacOS-X, etc..
No command dependancies external to Bash.
"

prez=abstain veep=abstain congressman=abstain senator=abstain
governor=abstain ltgovernor=abstain statesenator=abstain
staterep=abstain mayor=abstain TCOP=abstain executive=abstain
CCOP=abstain dogcatcher=abstain referendumone=abstain
referendumtwo=abstain referendumthree=abstain


allabstain () {
prez=abstain veep=abstain congressman=abstain senator=abstain
governor=abstain ltgovernor=abstain statesenator=abstain
staterep=abstain mayor=abstain TCOP=abstain executive=abstain
CCOP=abstain dogcatcher=abstain referendumone=abstain
referendumtwo=abstain referendumthree=abstain
}


formfeed () {
echo -e "\f";echo -e "\f";echo -e "\f";echo -e "\f"
echo -e "\f";echo -e "\f";echo -e "\f";echo -e "\f"
echo -e "\f";echo -e "\f";echo -e "\f";echo -e "\f"
echo -e "\f";echo -e "\f";echo -e "\f";echo -e "\f"
}

ding () {
echo -en "\007"
}


waitenter () {
echo " Hit Enter to continue "
read junkvariable
}



yesno () {
echo " Hit the letter 'y' for yes, an 'n' for no, or an 'a' for
abstain,
and hit Enter."
read choyce
case $choyce in
y|Y|yes|YES|Yes) yna=YES ;;
n|N|no|No|NO) yna=NO ;;
a|A) yna=abstain ;;
*) echo "
I couldn't reduce your input, $choyce, to a yes, no or abstain, so I'm
taking it as 'abstain'."
yna=abstain
waitenter ;;
esac
}


writein () {
formfeed
echo "
Type in your 'write-in' choice for this office and hit ENTER
"
read wrotein
}


checkem () {
formfeed
printballot
waitenter
}


newvcode () { # Simple gizmo to problematicize repeat voting
# Note to poll site proctors...
# change fluib and trUb to something unique
if test "$vcode" = "fluib" ; then
vcode=trUb
else
vcode=fluib
fi
}



pickpresident () {
formfeed
echo "
pick your preference for President of the United States of America

1 Richard Allen Hohensee Party of Ideas
2 JEB Bush Republican Party
3 John Forbes Kerry Democratic Party
4 Stewart Brand Green Party
5 Brad Pitt Socialist Party
6 Oprah Winfrey O Party
7 Colin Powell Libertarian Party
8 William Thomas Proposition One Party

w write in (type, actually) a vote
a abstain, no vote for this office

Hit an option number or letter from the left column and hit ENTER .


"
read choyce
case $choyce in
1) prez="Richard Allen Hohensee" ;;
2) prez="JEB Bush" ;;
3) prez="John Forbes Kerry" ;;
4) prez="Stewart Brand" ;;
5) prez="Brad Pitt" ;;
6) prez="Oprah Winfrey" ;;
7) prez="Colin Powell" ;;
8) prez="William Thomas" ;;

a|A) prez=abstain ;;
w|W) writein
prez=$wrotein ;;
*) halp ;;
esac
}

pickvicepresident () {
formfeed
echo "
make your vote for Vice President of the United States of America

1 G. Gordon Liddy Republican Party
2 Russell Feingold Democratic Party
3 Steve Wozniac Silicon Party
4 Nina Utne Green Party
5 Mary Carey Libertuna Party
6 Lindsey Graham Monarchist Party
7 Dr. Phil O Party
8 Eric C. Anderson Proposition One Party

w write in (type, actually) a vote
a abstain, no vote for this office

Hit an option number or letter from the left column and hit ENTER .


"

read choyce
case $choyce in
1) veep="G. Gordon Liddy" ;;
2) veep="Russell Feingold" ;;
3) veep="Steve Wozniac" ;;
4) veep="Nina Utne" ;;
5) veep="Mary Carey" ;;
6) veep="Lindsey Graham" ;;
7) veep="Dr. Phil" ;;
8) veep="Eric C. Anderson" ;;

a|A) veep=abstain ;;
w|W) writein
veep=$wrotein ;;
*) halp ;;
esac
}


pickrepresentative () {
formfeed
echo "
vote on Representative to the House from Wyoming

1 Lynndie England Republican Party
2 Jesse Ventura Vee Twin Party
3 Oliver North Monarchist Party
4 Cynthia McKinney Socialist Party
5 Tyler Westbrook Church of the Subgenius
6 Jerry Stein Party of Ideas

w write in (type, actually) a vote
a abstain, no vote for this office


Hit an option letter or number from the left column and hit ENTER .



"
read choyce
case $choyce in
1) representative="Lynndie England" ;;
2) representative="Jesse Ventura" ;;
3) representative="Oliver North" ;;
4) representative="Cynthia McKinney" ;;
5) representative="Tyler Westbrook" ;;
6) representative="Jerry Stein" ;;
a|A) representative=abstain ;;
w|W) writein
representative=$wrotein ;;
*) halp ;;
esac
}


picksenator () {
formfeed
echo "
vote for your US Senator from Wyoming

1 Noam Chomsky Party of Ideas
2 Tom DeLay Republican Party
3 Hillary Clinton Democratic Party
4 Mark Foley NAMBLA
5 Joe Leiberman Leiberman Klatch

w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .
"
read choyce
case $choyce in
2) senator="Tom DeLay" ;;
1) senator="Noam Chomsky" ;;
3) senator="Hillary Clinton" ;;
4) senator="Mark Fondle" ;;
5) senator="Joe Leiberman" ;;
a|A) senator=abstain ;;
w|W) writein
senator=$wrotein ;;
*) halp ;;
esac
}


pickstateofficers () {
mulling=yeah_hold_on
while test "$mulling" ; do
formfeed
echo "
vote on officers of the State of Wyoming

1 Governor
2 Lieutenant Governor
3 State Senator
4 State Representative
5 referenda

Hit an option number from the left column and hit ENTER .





"
read choyce
case $choyce in
1) pickgovernor ;;
2) pickltgovernor ;;
3) pickstatesenator ;;
4) pickstaterep ;;
5) pickstatereferenda ;;
*) mulling= ;;
esac
done
}


pickstatereferenda () {
mulling=uh_yeah
while test "$mulling" ; do
formfeed
echo "

Wyoming has 3 referenda this year. Type in a number from 1 to 3 to view

and possibly vote on that question to the electorate. (And hit Enter.
ANy other entry or just Enter will leave the referenda menu.)

"
read choyce
case $choyce in
1) formfeed
echo "
Referendum One


Enact a bill to outlaw cosmetic breast-reduction surgery (reduction
mameoplasty)?


"
yesno
referendumone=$yna ;;

2) formfeed
echo "
Referendum Two
Enact a bill to make it unlawful to lock a portable toilet?


"
yesno
referendumone=$yna ;;

3) formfeed
echo "
Referendum Three
Enact a bill banning margarine?



"
yesno
referendumone=$yna ;;

*) mulling= ;;
esac
done
}


pickgovernor () {
formfeed
echo "
pick your preference for Governor

1 Cindy Sheehan Party of Ideas
2 Rick Santorum Republican Party
3 Phil Donahue Democratic Party
4 Bruce Springsteen independant
5 Dr. J independant
6 Charles Barkley Party? Where?
7 Bill Gates virus detected
8 Neil Bush NAMBLA
w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .




"
read choyce
case $choyce in
1) governor="Cindy Sheehan" ;;
2) governor="Rick Santorum" ;;
3) governor="Phil Donahue" ;;
4) governor="Bruce Springsteen" ;;
5) governor="Dr. J" ;;
6) governor="Charles Barkley" ;;
7) halp ;;
8) governor="Neil Bush" ;;
a|A) governor=abstain ;;
w|W) writein
governor=$wrotein ;;
*) halp ;;
esac
}


pickltgovernor () {
formfeed
echo "
pick your Lieutenant Governor of Wyoming

1 Dianne Wilson Party of Ideas
2 John Bolton Republican Party
3 Michael Moore Democratic Party
4 Tony Blair Dunblane Party
5 Jay McGinley independant
6 Ray McGovern Monarchist Party

w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .


"
read choyce
case $choyce in
1) ltgovernor="Dianne Wilson" ;;
2) ltgovernor="John Bolton" ;;
3) ltgovernor="Michael Moore" ;;
4) ltgovernor="Tony Blair" ;;
5) ltgovernor="Jay McGinley" ;;
6) ltgovernor="Ray McGovern" ;;
a|A) ltgovernor=abstain ;;
w|W) writein
ltgovernor=$wrotein ;;
*) halp ;;
esac
}


pickstaterep () {
formfeed
echo "
vote for Representative to the Wyoming Assembly

1 Coleen Rowley Party of Ideas
2 Katherine Harris Republican Party
3 Lance Armstrong Democratic Party
4 Bill O'Reilly Monarchist Party
5 Richard Stallman BINC Is Not Communism
6 Eric S. Raymond Libertarian Party

w type in (write in) a vote
a abstain, no vote for this office


Hit an option letter or number from the left column and hit ENTER .




"
read choyce
case $choyce in
1) staterep="Coleen Rowley" ;;
2) staterep="Katherine Harris" ;;
3) staterep="Lance Armstrong" ;;
4) staterep="Bull S. O'Leilly" ;;
5) staterep="Richard Stallman" ;;
6) staterep="Eric S. Raymond" ;;

a|A) staterep=abstain ;;
w|W) writein
staterep=$wrotein ;;
*) halp ;;
esac
}


pickstatesenator () {
formfeed
echo "
Senator for Wyoming State Senate

1 Joseph Darby Party of Ideas
2 Andrew Dice Clay Republican Party
3 Howard Dean Democratic Party
4 Kweisi Mfume Libertuna Party
5 Calvin Klein Monarchist Party

w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .




"
read choyce
case $choyce in
1) statesenator="Joseph Darby" ;;
1) statesenator="Andrew Dice Clay" ;;
3) statesenator="Howard Dean" ;;
4) statesenator="Kweisi Mfume" ;;
5) statesenator="Calvin Klein" ;;
a|A) statesenator=abstain ;;
w|W) writein
statesenator=$wrotein ;;
*) halp ;;
esac
}


pickcountyofficers () {
stillmulling="yes"
while test "$stillmulling" ; do
formfeed
echo "
vote on officers of Elknip County

1 Executive
2 Chief of Police
3 Dog Catcher

Hit an option number or letter from the left column and hit
ENTER . Anything other than the given numbers will leave the
county offices menu.






"
read choyce
case $choyce in
1) pickexecutive ;;
2) pickCCOP ;;
3) pickdogcatcher ;;
*) stillmulling= ;;
esac
done
}


pickexecutive () {
formfeed
echo "
vote for Executive of Elknip County

1 Alf Who Knew? Party
2 James Hill Democratic Party
3 Rush Limbaugh Reublican Party
4 Kristen Breitweiser Party Of Ideas
5 Paul Thompson independant
6 Marvin Bush Party In Building 7

n NONE OF THE ABOVE, fill office by lottery from persons
in
jury duty lists
w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .



"
read choyce
case $choyce in
1) executive="Alf" ;;
2) executive="James Hill" ;;
3) executive="Rush Limbaugh" ;;
4) executive="Kristen Breitweiser" ;;
5) executive="Paul Thompson" ;;
6) executive="Marvin Bush" ;;

n|N) executive="LOTTERY" ;;
a|A) executive=abstain ;;
w|W) writein
executive=$wrotein ;;
*) halp ;;
esac
}


pickCCOP () {
formfeed
echo "
vote for Chief of Police of Elknip County

1 Ted Hendricks Party of Ideas
2 Laura Bush Republican Party
3 Rick Derringer Democratic Party
4 Neil Olkowitz independant
5 Jack Lambert independant

w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .





"
read choyce
case $choyce in
1) CCOP="Ted Hendricks" ;;
2) CCOP="Laura Bush" ;;
3) CCOP="Rick Derringer" ;;
4) CCOP="Olkie" ;;
5) CCOP="Jack Lambert" ;;
a|A) CCOP=abstain ;;
w|W) writein
CCOP=$wrotein ;;
*) halp ;;
esac
}


pickdogcatcher () {
formfeed
echo "
vote for dogcatcher for Elknip County

1 Dave bla Party
2 Bey zay Party
3 Ed woof Party
4 Frank WOOF Party
5 Marbella independant

w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .



"
read choyce
case $choyce in
1) dogcatcher="Dave" ;;
2) dogcatcher="Bey" ;;
3) dogcatcher="Ed" ;;
4) dogcatcher="Frank" ;;
5) dogcatcher="Marbella" ;;
a|A) dogcatcher=abstain ;;
w|W) writein
dogcatcher=$wrotein ;;
*) halp ;;
esac
}


pickcityofficers () {
stillmulling="yes"
while test "$stillmulling" ; do
formfeed
echo "
vote on officers of East Jesus Township

1 Mayor
2 Chief of Police

Hit an option number or letter from the left column and hit
ENTER, or anything else and Enter to return to the main screen.

"
read choyce
case $choyce in
1) pickmayor ;;
2) pickTCOP ;;

*) stillmulling= ;;
esac
done
}


pickmayor () {
formfeed
echo "
vote for Mayor of East Jesus Township

1 Alf bla Party
2 Curly zay Party
3 Bugs woof Party

w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .
"
read choyce
case $choyce in
1) mayor="Alf" ;;
2) mayor="Curly" ;;
3) mayor="Bugs" ;;
a|A) mayor=abstain ;;
w|W) writein
mayor=$wrotein ;;
*) halp ;;
esac
}


pickTCOP () {
formfeed
echo "
vote for Chief of Police of East Jesus Township

1 Alf bla Party
2 Curly zay Party
3 Bugs woof Party

w type in a 'write-in' vote
a abstain, no vote for this office

Hit an option letter or number from the left column and hit ENTER .


"
read choyce
case $choyce in
1) TCOP="Alf" ;;
2) TCOP="Curly" ;;
3) TCOP="Bugs" ;;
a|A) TCOP=abstain ;;
w|W) writein
TCOP=$wrotein ;;
*) halp ;;
esac
}



votetally () { # less-than-universal echo -e because tabs make nice
# record delimiters.
echo -e "
$voterUID\t$prez
$voterUID\t$veep
$voterUID\t$senator
$voterUID\t$congressman
$voterUID\t$governor
$voterUID\t$ltgovernor
$voterUID\t$statesenator
$voterUID\t$staterep
$voterUID\t$referendumone
$voterUID\t$referendumtwo
$voterUID\t$referendumthree
$voterUID\t$executive
$voterUID\t$CCOP
$voterUID\t$dogcatcher
$voterUID\t$mayor
$voterUID\t$TCOP
"
}


printballot () {
echo " OFFICIAL BALLOT the United States of America
Precinct Null, East Jesus Township, Elknip County, Wyoming
Nov2008

President $prez
Vice President $veep
Senator $senator
Congressman $congressman

Governor $governor
Lt. Governor $ltgovernor
State Senator $statesenator
State Representative $staterep
referenda
#1 $referendumone #2 $referendumtwo #3 $referendumthree

County Executive $executive
County Chief of Police $CCOP
Dogcatcher $dogcatcher

Mayor $mayor
City Chief of Police $TCOP

$voterUID
"
}


halp () {
formfeed
echo "

Your input, '$choyce', doesn't match any of the menu option
index letters. That's a problem for this particular options
screen. Please use the letters shown to select menu items. I
will send you back to the main menu when you hit the ENTER key,
but if that doesn't make sense you may wish to seek assistance
from a poll monitoring person.

Hit the ENTER key to return to the main menu.

"
waitenter
}


vcodehint () {
if test $vcode = trUb ; then # when you change trUb change it
here too
echo "
TTTTTTTTTTT
TTTTTTTTTTT
TT
TT
TT
TT
TT
TT
"
else
echo "
FFFFFFFFFF
FFFFFFFFFF
FF
FF
FFFFfF
FFFFFf
FF
FF
FF
FF
"
fi
}



finishvoter () {
formfeed
if test "$prez" = "abstain" ; then
formfeed
echo "

You have selected the q option to finalize your ballot editing session,

but you haven't chosen a candidate for President of the United States.
You may want to ask for assistance before hitting another key, unless
you actually intend to actively abstain from voting for President,
which
this system asks you about because few people would really want to do
that.

"
waitenter
fi
echo "
This is it. The next time you hit ENTER with no other keys your final
official ballot will be printed out, your anonymously IDed reciept will

then be printed out, and your votes will be added to the electronic
unofficial tally. If you aren't really ready to finalize editing your
ballot hit n before hitting ENTER .
"
read scratch
if test "$scratch" ; then
formfeed ## just don't clear
$hasnotvoted
else # print and tally
hasnotvoted=
ding
votetally >> /mnt/dos/tallyNov82008
printballot > /dev/lp0
formfeed > /dev/lp0
echo $voterIUD > /dev/lp0
formfeed > /dev/lp0
echo "

Thank you for your crucial contribution to the democratic process of
the
United States of America in Precinct Null, Elknip County, East Jesus
Township, Wyoming. When your ballot and receipt are done printing, fold

them if you like, take the ballot to the ballot box, and insert the
ballot in the box. Keep or discard your receipt, (the paper with just a

long number printed on it,) but please don't put the receipt in the
ballot box.

"
sleep 20
fi
}

perVoter () { # per-voter
voterUID=$RANDOM$RANDOM$RANDOM$RANDOM
while test "$hasnotvoted" ;do
formfeed
echo "

You can change your vote for any item until you select the f item,
which
will ask for confirmation, and then your official ballot will be
printed
out and the electronic copy of your vote will be recorded.

national officers 1 President
2 Vice President
3 Senator
4 Congressman

State and local officers and referenda
5 State officers
6 State referenda
7 County officers
8 City officers

p preview how your ballot will look if you
quit editing and record your vote now
o Start over; reset all your votes to
abstain
f finish and print your paper ballot, tally
your votes and quit

Hit an option number or letter from the left column and hit ENTER .
"

read choyce
case $choyce in
1) pickpresident ;;
2) pickvicepresident ;;
3) picksenator ;;
4) pickrepresentative ;;

5) pickstateofficers ;;
6) pickstatereferenda ;;
7) pickcountyofficers ;;
8) pickcityofficers ;;

p|P) checkem ;;
o|O) allabstain
checkem ;;
f|F) finishvoter ;;
*) halp ;;
esac
done
}



votescript () { # top endless loop of voter interface,
# ctrl&C and so on should be disabled here in the real deal, maybe with

#Bash keymapping?

vcode=fluib
while true ;do # i.e. always
allabstain
formfeed
vcodehint
echo "
Please type in your voter key and hit ENTER

"
read vcodeTry
if test "$vcodeTry" = count ; then
echo $VOTERS
waitenter
fi
if test "$vcodeTry" = "$vcode" ; then
newvcode
hasnotvoted=true
perVoter
let VOTERS=$VOTERS+1
else
ding
fi
done
}


Similar Posts