[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bayonne-devel] Building libexec apps in bayonne2, how easy it is
From: |
David Sugar |
Subject: |
[Bayonne-devel] Building libexec apps in bayonne2, how easy it is |
Date: |
Mon, 02 Jan 2006 21:24:40 -0500 |
User-agent: |
Mozilla Thunderbird 1.0.7 (X11/20051011) |
To get an idea how trivial it now is to build libexec applications in
Bayonne 2; while they can be written in perl with things like the
libexec.pm module, it is possible to run libexec directly to simple
bashj shell scripts that require trivial code to parse arguments and
return results. Consider a libexec shell script to return diskspace
through df:
in /usr/share/bayonne/libexec/sys-df.sh:
fs="$ARGS_FILESYSTEM"
df=`df $fs | tail -n 1`
df=`echo $df | cut -d\ -f5`
echo "$PORT_TSESSION result $df"
The ARGS_xxx is autofilled in the environment on the libexec call for
you (there is also HEAD_xxx envs), which can look something like:
string %myspace
libexec lib::sys_df.sh filesystem="/" results=&myspace
This can then be wrapped into a macro file such as "libexec.mac" for
convience, like:
macro diskspace
keywords results filesystem
libexec lib::sys_df.sh results=&results %filesystem
return
And used with:
import libexec
string %result
libexec::diskspace filesystem="/" results=&result
Offering a very clean interface with compile-time prototype (argument)
checking. In fact, argument checking is the principle reason to use a
macro wrapper, as then if you mistype an argument, like using filesys=
instead of filesystem=, you will get a compile time error, rather than a
raw libexec call, which accepts arbitrary arguments.
dyfet.vcf
Description: Vcard