2010-09-24 180 views
1

我的桌面上运行着Rhythmbox,我希望能够通过Web界面远程控制它。但是,我在访问时遇到了问题,因为rhythmbox-client抱怨试图访问它的用户(www-data)没有a)X会话正在运行,并且b)无法访问我的rhythmbox dbus信息。从其他用户获取rhythmbox信息

(rhythmbox-client:13954): Rhythmbox-WARNING **: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.

我跑了Apache,PHP在Ubuntu 10.04。下面的方法也受到来自不同的用户通过调用PHP CLI PHP脚本尝试(ssh方式连接到我自己的盒子用不同的用户)

我已经试过这些方法:

  • 呼叫系统( )和exec()与“rhythmbox客户端 - 打印播放 - 无开始 - 无重发”
  • 使用DBUS直接在PHP以及一个Python脚本(从PHP调用它)脚本与系统()/ exec())
  • 使用setuid()setruid(),seteuid()在C程序中并调用它通过PHP。

我现在处于亏损状态。这甚至有可能吗?

[编辑] 我已使用@ IvanGoneKrazy的建议,并从this similar question采取环境代码。现在,我有这样的代码跟此错误消息:

import subprocess, os 

p = subprocess.Popen('dbus-launch', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 
for var in p.stdout: 
    sp = var.split('=', 1) 
    os.environ[sp[0]] = sp[1][:-1] 

os.system('rhythmbox-client --print-playing') 

错误消息:

(rhythmbox-client:15377): Rhythmbox-WARNING **: Launch helper exited with unknown return code 1 

回答