0

I am trying to execute the command exec('vlc'); from php script (in linux), but then, the page (php) has not been loaded. Even by using pcntl_fork (for exec command) this is not working.

But if I am trying to run from command line php -S localhost:8000 -t path/to/src, and enter localhost:8000/page.php in the browser, the page has been loaded and the vlc opened.

What is the problem ?

Note: If I am trying to run from command line php -r "exec('vlc');" the vlc opened.

In addition, I checked and the php not working in safe mode.

Update1:

<?php
echo shell_exec('vlc');
?>

**** not working ****

<?php
echo shell_exec('vlc 2>&1');
?>

The output:

Home directory not accessible: Permission denied [08ea1490] pulse audio output error: PulseAudio server connection failure: Connection refused [08e9e448] core interface error: no suitable interface module [08ded0d0] core libvlc error: interface "globalhotkeys,none" initialization failed [08e9e448] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 [08e9e448] core interface error: no suitable interface module [08ded0d0] core libvlc error: interface "dbus,none" initialization failed [08ded0d0] core libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. [08e9e448] qt4 interface error: Could not connect to X server [08e9e448] skins2 interface error: cannot initialize OSFactory [08e9e448] [cli] lua interface: Listening on host "*console". VLC media player 2.2.0 Weatherwax

<?php
echo shell_exec('whoami');
?>

The output: www-data

/var/log/httpd  

not exists

but /var/log/apache2/error.log exists and:

Home directory not accessible: Permission denied
[0980c490] pulse audio output error: PulseAudio server connection failure: Connection refused
[09809448] core interface error: no suitable interface module
[097580d0] core libvlc error: interface "globalhotkeys,none" initialization failed
[09809448] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[09809448] core interface error: no suitable interface module
[097580d0] core libvlc error: interface "dbus,none" initialization failed
[097580d0] core libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[09809448] qt4 interface error: Could not connect to X server
[09809448] skins2 interface error: cannot initialize OSFactory
[09809448] [cli] lua interface: Listening on host "*console".
[09809448] [cli] lua interface: Requested shutdown.

Update2:

shell_exec("DISPLAY=:0  vlc");

working, but very slowly (with php -S ... , is faster).

I trying

 shell_exec("DISPLAY=:0  vlc v4l2:///dev/video0 --sout '.settings.'");

(with some settings) but I received an error

[b4602c50] mux_ogg mux: Open
[b4604a30] v4l2 demux error: cannot open device '/dev/video0': Permission denied
[b4604a30] v4l2 demux error: cannot open device '/dev/video0': Permission denied
[b4604a30] v4l2 access error: cannot open device '/dev/video0': Permission denied
[b4b04ea0] core input error: open of `v4l2:///dev/video0' failed
[b4b04ea0] core input error: Your input can't be opened
[b4b04ea0] core input error: VLC is unable to open the MRL 'v4l2:///dev/video0'. Check the log for details.
[b4602c50] mux_ogg mux: Close

but with php -S ... is working .

What is the problem ?

Thanks in advance

1 Answer 1

0

I do not have enough reputation to post comments, which makes debugging a little bit difficult. First check your your error log in /var/log/httpd and see if there is anything obvious there. If there is nothing there, Can you execute this and tell us if this does anything?

<?php
echo shell_exec('vlc');
?>

if this does nothing do

<?php
echo shell_exec('vlc 2>&1');
?>

and

<?php
echo shell_exec('whoami');
?>
Sign up to request clarification or add additional context in comments.

4 Comments

Execute it as a user that has x11 configured. stackoverflow.com/questions/3149341/…
do full on sudo -u some_user vlc , and change your permissions on sudo to allow www-data to run sudo -u some_user vlc
No, this is not working. And what do you mean by "change your permissions on sudo to allow www-data" ?
In order to change user without having to type a password you have to either go through a lot of configuration or do it with sudo. By default, www-data is not allowed to run any sudo commands, and if you try to do anything with sudo using shell_exec, you will either get a prompt for password, or see a warning of some sort... cyberciti.biz/tips/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.