Who will win the election?


Okay, it’s the election time here in Sri Lanka. The presidential election will be held on 26th January 2010. As the heat continue to build, I thought of writing a small script to get to know who will win the election as people think. To make it more user friendly, had to add some GUI features. Hadn’t known how to use these message boxes, etc before, but a simple search in google provided the answers. Here’s the script:


name=$(zenity --entry --text "Please enter your name" 
   --entry-text "" --titleย "Presidential Election 2010")
if [ $? != 0 ]
exit 0

vote=$(gdialog --title "Presidential Election 2010" --radiolist 
   "Who will win?" 60 100 10 1 Mahinda Rajapaksha 2 Sarath 
   Fonseka 2>&1)

if [ $vote = "1" ]; then
if [ $vote = "2" ]; then

result="$result $name"
echo $result >> results

The script will first prompt the user to enter his name. If he didn’t press Cancel in that name entry box, it will show the user a box with two radio buttons with the names of the two candidates, Mahinda Rajapaksha and Sarath Fonseka. Once the user selects an answer and presses Ok that vote will be appended to a text file results along with his name.
The Zenity thing in the script is way to display dialog boxes and such GUI accessories in the shell scripts. Hope to add more of this later.

As far as the votes in our boarding place are concerned, more than 90% percent think Mahinda will win the election. Let’s place that choice in the voters’ hands. ๐Ÿ™‚


7 Responses to “Who will win the election?”

  1. 1 Thilanka

    Sha ape adahasa wada karala wage neda. mama c# walin karana eka goda dannam.

  2. By the way, the presidential election will be held on 26th of January 2010..

  3. oh sorry, please delete my previous comment ๐Ÿ˜€

  4. 6 wijaya

    2005 Presidential Election result was
    Mahinda Rajapakse United People’s Freedom Alliance – 4,887,152 and 50.29%

    Ranil Wickremesinghe
    United National Party 4,706,366 and 48.43%

    In 2005 JVP votes were given to Mahinda Rajapaksha. According provincial council election results, there are more than 234,000 votes for JVP. If we think half of that will vote Mahinda and other half will vote for Genaral Fonseka the result will be 4,823,366 for Fonseka and 4,770,152 for Mahinda. Based on that we can imagine Fonseka’s victory though we ignore other facts.

    I voted for Mahinda last time. But here I’m voting for Fonseka this time.

  5. 7 hello

    SF should win this other wise end of the countries future. becouse all SLFP polititions are currupted gov. money robbers. basil take 10% of all gov. contracts. and other ministers also doing the same and mervin silva (maraya,kudu raja) doing what he wants looking this nonsense MR keep quite no action. no back born to refuse these illegal actions.

    SF will defenitly resolve all these curruptions as soon when he win.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: