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.
begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Telephony
email;internet:[EMAIL PROTECTED]
tel;work:+1 201 215 2609
x-mozilla-html:FALSE
url:http://www.gnutelephony.org
version:2.1
end:vcard
_______________________________________________
Bayonne-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bayonne-devel