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
)
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.