Using Haserl scripts for HTML based Runtime Configuration and Monitoring
For many projects its a good idea to have your users use a browser to view the device state and do runtime configuration for the device.
Of course you need to have a Flash file system to store the configuration values. See the appropriate articles on Flash and on rc-Files on how to install a Flash file system and use it for holding system variables in one or more configuration files.
Usually, when doing runtime configuration via http, you need to write a cgi-program (in C or a scripting language like php) that takes the user's inputs and creates html code, that the http server can send to the client's browser. Writing a dedicated C program seems a lot too high level for the simple task we want to accomplish here, and learning php as an additional language and implementing the php interpreter also does not seem appropriate for a small embedded device.
Haserl is a quite small tool that allows to write scripting code directly in normal html pages. Moreover it does not contain a scripting language interpreter but can be used (e.g.) with an existing command line (shell script) interpreter like bash or hush (or lua, if you need a scripting language specially designed for cgi use). Thus the haserl scripts are a mixture of html and shell script code and you don't need to create html code programmatically and/or provide as well a program and some html based pages. The haserl scrips can be created using a html editor like Quanta.
haserl is provided as a "miscellaneous program" with the µCLinux distr.
hush is part of the busybox.
The web server boa is provided with the µCLinux distr.
Attached here, you'll find a file that contains haserl scripts and shell scripts that work together to show some system states on a web page and allow for some common realtime configuration settings like "use DHCP" and "use IP-Address".
echo.c: This utility was designed for msh and is not needed with hush.
romfs.tar.gz: Part of a NEEK romfs, containing haserl script files and complex rc init scripts that work together to e.g., manage the IP address of a device. For new designs please replace "/bin/msh" by /bin/hush" appropriately.
If using haserl with boa 0.94.13, you need to do a
somewhere and add a line like
syslog(LOG_DEBUG, "haserl start");
and e.g. in main() in the haserl code and the sylog daemon is activated. (right now nobody seems to know why it does not work otherwise. It does work when called from a command line and it works with boa on a PC.) Happily this problem magically disappeared with upgrading to boa 0.94.14 !
Haserl makes heavy use of the echo command, both because it uses echo when handling the script and because each haserl script will contain lots of echo commands (or "<%: some text maybe containing $VARIABLES %>" phrases that haserl converts to echo commands.) Fortunately hush (other than msh) has a builtin command "echo" and "test (aka "[" ), so no external and slow loading executables for thoase are necessary.
If using haserl with boa 0.94.14, you need to do hush commands like
<% if [ "$X" = "Y" ]; then %>
<% if [ $X = Y ]; then %>
even though msh/hush does accept
if [ $X = Y ]; then
in a normal script.
I don't know why the additional "s are necessary, but if you drop them you'll see error messages on the console when a haserl script is executed. (There were no such error messages when using the same haserl version with boa 0.94.13)
echo.c - This utility was desigend for use with msh and is not needed with hush.
romfs.tar.gz - Part of a NEEK romfs, containing haserl script files and complex rc init scripts that work together to e.g. manage the IP address of a device. For new designs please replace "/bin/msh" by "/bin/hush" appropriately
Community support is provided during standard business hours (Monday to Friday 7AM - 5PM PST). Other contact methods are available here.
Intel does not verify all solutions, including but not limited to any file transfers that may appear in this community. Accordingly, Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.