douzepao0281 2015-12-03 16:23
浏览 74
已采纳

PHP shell_exec不适用于gnome

In a terminal window running alert 9 gives me a popup saying 9

However, running alert 9 in shell_exec gives nothing.


What should I be aware of?

Just to mention: other commands work neither that interact with the GUI. I am using gnome 3.16.3


UPDATE

My concrete goal is to run an xdotool command using the gnome environment. ( xdotool key ctrl+shift+u )

  • 写回答

3条回答 默认 最新

  • duanliao3826 2015-12-07 16:50
    关注

    alert is not a command, but an alias for notify-send. Aliases are loaded only in interactive shell, so it is not the best choice to test shel_exec.

    These 2 command work well with php-cli:

    $ php -r "shell_exec('notify-send 9');"
    $ php -r "shell_exec('xdotool key ctrl+shift+u');"
    

    The first one pops the 9 in notification area, and the last one output underscored 'u'.

    Apache with mod_php is a daemon, subprocess of init, which knows nothing about xserver. If, for example, you run php built-in web server from a terminal within xserver like $ php -S 0:8080 it works as expected.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题