List Info

Thread: For 1.0.6/1.1.5, more examples of how to do "interesting" things...




For 1.0.6/1.1.5, more examples of how to do "interesting" things...
user name
2006-01-02 23:55:43
I found the libexec scripts did not get properly installed
in prior
releases.  But in any case, I have also written some sample
shell
scripts executed under btsexec, and wrapped in a new
"libexec" macro
library.  These macros are used to report things like system
uptime,
ifconfig, and disk space back into a bayonne script, and
provide simple
and direct examples of how to write simple shell scripts as
interactive
libexec's (that both receive arguments and return results)
and how to
wrap then in a macro library.


_______________________________________________
Bayonne-devel mailing list
Bayonne-develgnu.org
h
ttp://lists.gnu.org/mailman/listinfo/bayonne-devel
Building libexec apps in bayonne2, how easy it is
user name
2006-01-03 02:24:40
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.

_______________________________________________
Bayonne-devel mailing list
Bayonne-develgnu.org
h
ttp://lists.gnu.org/mailman/listinfo/bayonne-devel
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )