Sunspot Home . . . . . . Joggler menu

Running CGI scripts from a web page to run C code, Sox, flite etc
-to first control the backlight and the Joggler i2c light sensor and (later) i2c external devices

In my (Debian)Slug and (Openwrt)Sweex and (Debian)Bifferboard I can run cgi scripts in /var/www/cgi-bin and have these run in turn bash scripts that can then run C code, sound players, text to speech etc.

On (Ubuntu)Joggler using lighttpd as downloaded I can run bash scripts and Blassic basic but NOT Flite, Sox, readlightsensor etc even though these run fine when I run the bash scripts that call them in a root SSH terminal.

The answer is to run lighttpd as root (just as in my other platforms)
BUT the Ubuntu lighttpd download refuses to do so!!
The fix is here

I have a set of scripts that use cgi files in /var/www/cgi-bin/scripts that allow a link on a web page to run Joggler programs.

 How the scripts work (current work backup - just a test to be modified later as needed)

The demo web page below is called after loading




#Decode query string

QKEY="`echo $QUERY_PARTS | cut -d '=' -f 1`"
QVAL="`echo $QUERY_PARTS | cut -d '=' -f 2`"
eval "`httpd -d "$QKEY"`=\"`httpd -d "$QVAL"`\""
# remove next line for OpenWrt
eval "$QKEY=\"$QVAL\""

# when the page is first opened load the text from
# this page is addressed like ->
# index.cgi?page=rs232send&string=HARRY
# so the values of both page and string are sent to this script
# thus if page=rs232send the script we run will be

# has the variable page been given a value?
if [ -e "pg-$" ]; then

# if not then show the default text

echo "Content-type: text/html"

#send first part of the html page
cat scripts.html
echo "<!-- Content goes here -->"
. $inc
echo "<!-- End of content -->"
echo "scripts.cgi now printing to the web page"
echo "<BR>Uptime: `cat /proc/uptime | cut -d ' ' -f 1` seconds.<br>"
# now finish the html
echo "<BR></body></html>"
#cat path_to/end.html <-use for a more complex end to the page

The top part of the page is built by
scripts.cgi from :-


<!HTTP/1.0 200>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<body bgcolor="#FFFFCC">

<font color="#009900" size="4" face="Arial, Helvetica, sans-serif"><strong>Joggler Control Scripts</strong></font></p>
<p><strong><font color="#FF0000" size="3" face="Arial, Helvetica, sans-serif"><HR>run a script </font></strong></p>

<font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/">sound test </a></font> </font>


<font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/">read light level</a></font>

<font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/">play wav with Sox</a></font>

<font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/">bright screen</a></font>
- - - - -

<font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/">dim screen</a></font>
- - - - -

<font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/">dark screen</a></font>

the clicked link makes page = scripts and so the file runs



# send all this to the web page

echo '<font color=blue size=3 face=Arial>'
echo 'now running the script '
echo '</font>'

echo '<font color=red size=3 face=Arial>'
echo $string
echo '</font><BR>'

# run the script with the name string

$string runs this if the clicked link made string=/var/www/cgi-bin/scripts/



echo "<BR> sound test now <BR>"

flite -t ' eff lite is speaking '

date runs this if the clicked link made string=/var/www/cgi-bin/scripts/



echo "<BR><BR>Joggler light sensor value = "

# dump the first reading - seems to be in memory from last time light level was read
readlightsensor >> /dev/null 2>&1

# now write the light reading to the web page

echo "<BR><BR>"

flite -t 'the light level is'
flite -t `readlightsensor`
date runs this if the clicked link made string=/var/www/cgi-bin/scripts/



play /home/graham/sounds/online.wav

echo "<BR><BR>"

date runs this if the clicked link made string=/var/www/cgi-bin/scripts/



echo -n 32 > /sys/class/backlight/openframe-bl/brightness

echo "<BR>Screen brightness is now 32 <BR><BR>"



Then scripts.cgi closes the html to finish the page.


The default below is used when is first called by the browser



#Generate the message that is first seen

echo "<BR><font color=red size=3 face=Arial>"
echo "this message comes up when the main script is first used<BR>"
echo "normally says - - PLEASE CLICK ON A LINK ABOVE<BR>"
echo "</font>"


Remove the scroll bar in the Joggler Firefox display
My home page is a table matrix of 11 x 7 icons that are 60 x 60 pixels each (easy to click on with a finger tip).
There are also some Google Gadgets (weather, birthdays, clock) and the BBC iPlayer gadget.
To save precious screen area I wanted to remove the scroll bar on the right of the Firefox screen when in full screen mode.
Install Stylish as a Firefox add-on.

By following these instruction I added a script to kill the scroll bar for the home page URL only
(as displayed in the Joggler - remote users still see the scroll bar)
The script to add is


@namespace url(;

scrollbar {visibility:collapse !important; }




Notes for future use
Sound volume control
The sound volume van be controlled from the command line
(perhaps in a script controlled by a web page) to any percentage of full on with, for example
amixer -c 0 -- sset Master playback 90%

Sunspot Home. . . . . Joggler menu