Answer the question
In order to leave comments, you need to log in
Perl, Net::DBus, session bus usage?
I understand with Net:: DBus, for testing I want to write two simple programs, one provides an interface, the other uses it.
I wrote a simple test code:
#!/usr/bin/perl
use strict;
use warnings;
package MyObj;
use Net::DBus::Exporter qw(org.example.Tao);
use base qw(Net::DBus::Object);
sub new {
my $class = shift;
my $service = shift;
my $self = $class->SUPER::new($service, '/MyObj');
bless $self, $class;
return $self;
}
dbus_method("Hello", ["string"]);
sub Hello {
return 'Hello';
}
package main;
use Net::DBus;
use Net::DBus::Reactor;
my $bus = Net::DBus->session;
my $service = $bus->export_service("org.example.Tao");
my $object = MyObj->new($service);
my $reactor = Net::DBus::Reactor->main();
$reactor->run();
return 0;
Perl, v5.8.8 built for x86_64-linux-thread-multi<br/>
Linux example.com 2.6.32.19-0.2.99.17.22250fd-xen #1 SMP 2010-09-13 10:16:50 +0200 x86_64 x86_64 x86_64 GNU/Linux<br/>
CentOS release 5.4 (Final)<br/>
org.freedesktop.DBus.Error.Spawn.ExecFailed:<br/>
Failed to execute dbus-launch to autolaunch D-Bus session<br/>
org.freedesktop.DBus.Error.Spawn.ExecFailed: <br/>
dbus-launch failed to autolaunch D-Bus session: <br/>
Autolaunch error: X11 initialization failed.<br/>
DBUS_SESSION_BUS_ADDRESS is empty:<br/>
[[email protected] perl]# ps ax|grep dbus|grep -v grep<br/>
1019 ? Ss 0:00 dbus-daemon --system<br/>
[[email protected] perl]# dbus-launch --sh-syntax<br/>
DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-smHadq6yxV,guid=101ccd74fb75ae501485ed004e2a9043';<br/>
export DBUS_SESSION_BUS_ADDRESS;<br/>
DBUS_SESSION_BUS_PID=5037;<br/>
[[email protected] perl]# ps ax|grep dbus|grep -v grep<br/>
1019 ? Ss 0:00 dbus-daemon --system<br/>
5037 ? Ss 0:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session<br/>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question