register bash script as dbus object

Александр Лавриненко lavrinenko_alex at mail.ru
Fri Dec 12 04:06:17 PST 2008


В сообщении от Пятница 12 декабря 2008 Matthew Johnson написал(a):
> On Fri Dec 12 12:38, Александр Лавриненко wrote:
> > В сообщении от Пятница 12 декабря 2008 Thiago Macieira написал(a):
> > > On Friday 12 December 2008 07:12:01 Александр Лавриненко wrote:
> > > > The problem is that this
> > > > daemon app needs to be written as bash script.
> > >
> > > Why are you imposing this requirement?
> >
> > Well, bash is also good for writing daemons. At least i have some for my
> > needs. Instead of rewriting them in C i tried to add dbus functionality
> > but failed to find a way.
>
> Actually, I would really encourage you not to write daemons in bash.
> Certainly not ones which use DBus, since there's no support for this and
> no way to do it afaik.
Why no way? Say, connect to dbus, announce itself and wait for methods from 
clients could be done with:

...
connect-dbus-object-from-script bla-bla-bla......| while (read string ; do
<process 'string' here into var and val>
case var in
bla-bla)
do-smth;;
agr-agr)
do-anthr;;
oh-oh)
default-action
esac
done
...

but there's no "connect-dbus-object-from-script" or similar program to use 
from scripts (nevermind the syntax - this is just conceptual example).

> If writing them in C is hard, you could try python instead. This has
> good DBus support and should be relatively easy to write the simple
> things you can do in bash.
C is not harder than [ba]sh for me. Shellscripting is:
a) easier and faster to write/debug
b) easily portable without compile to any arch
Python is out of my scope - target system may have it not installed and i 
don't want to learn yet another computer lang :(

> > Moreover, for some simple tasks one can write bash script that is called
> > on demand and register it with dbus - but there's no way currently as i
> > see.
>
> I suppose you could write something which just forked a bash script with
> the function arguments as parameters, but I don't know that any one has
> done so. I'm unconvinced that it wouldn't be easier just to write the
> script in python in the first place.
>
> Matt
It's pity that essential command line/scripting support is ommitted in dbus...

Best regards,
-- 
Alexander Lavrinenko


More information about the dbus mailing list