I'm trying to run dbus-send in a remote system but somehow I'm not able to run it. But the same dbus-send, if I run it in the local system, is working fine.


ssh remote@xx.xx.xx.xxx "dbus-send --print-reply --dest=service.name /object/path object.path.Service.method string:"XYZ""

How can I run dbus-send command from the remote system?


Linux 3.13.0-29-generic Ubuntu i686 GNU/Linux

  • What is the error you are getting? since you are inside an SSH session (not a desktop session) dbus-send probably cannot find which session bus to connect to - it may be enough to set the DISPLAY variable to that of the remote session e.g. "DISPLAY=:0 dbus-send ..."; otherwise you will need to extract and set the actual DBUS_SESSION_BUS_ADDRESS – steeldriver Sep 2 '14 at 10:54
  • Actually I'm extracting DBUS_SESSION_BUS_ADDRESS and the value is unix:path=/run/user/1000/bus but still i'm not able to execute dbus-send – Thushi Sep 2 '14 at 12:33
  • That looks like a location not an actual address value - did you try the source command from @chaos's answer? – steeldriver Sep 2 '14 at 12:41
  • @steeldriver: Nope,It's not working.Error: cat: /var/lib/dbus/machine-id: No such file or directory bash: ~/.dbus/session-bus/-0:Permission denied – Thushi Sep 2 '14 at 13:37

dbus-send needs some evironment variables to connect to the dbus-session. First you need to estimate them. First ssh to your machine.

The $DISPLAY variable:

DISPLAY=$(strings /proc/$(pgrep -n Xorg)/environ | awk -F== '$1 ~ "DISPLAY"{print $2}')

The dbus session variables:

source ~/.dbus/session-bus/$(cat /var/lib/dbus/machine-id)-0

Now you can place your dbus-send command.

  • I'm setting DBUS_SESSION_BUS_ADDRESS. Along with that do I need to set DISPLAY variable also? – Thushi Sep 2 '14 at 12:37
  • @Thushi Yes, if you don't X11 initialization failed would occur. – chaos Sep 2 '14 at 12:41
  • I'm using mutter window manager.Is that fine with DISPLAY variable? – Thushi Sep 2 '14 at 13:30
  • @Thushi yes, that doesn't matter – chaos Sep 2 '14 at 13:31
  • K.But If I run that command I'm getting the following error. cat: /var/lib/dbus/machine-id: No such file or directory bash: ~/.dbus/session-bus/-0:Permission denied – Thushi Sep 2 '14 at 13:34

Why are tou using a semicolon ? this make a new command on local host.

try using

ssh remote@xx.xx.xx.xxx "dbus-send --print-reply --dest=service.name /object/path object.path.Service.method string:XYZ"

Also note, that /object/path is on remote host.

next try: try addind /usr/bin (if fact, on remote host, isseu which dbus-send to know exact path).

ssh remote@xx.xx.xx.xxx "/usr/bin/dbus-send --print-reply --dest=service.name /object/path object.path.Service.method string:XYZ"

can you provide error message ?

  • Yeah..I tried your solution.Still it is not working for me and edited the question also. – Thushi Sep 2 '14 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.