I want to play music through PHP on my raspberry Pi using Mocp (music on the console). This team
mocp -S
works fine in the console (it starts the mocp server), but in the PHP exec function it doesn't work:
<?php
$ret = exec("mocp -S", $out, $err);
print_r($ret);
print_r($out);
print_r($err);
?>
It just returns:
Array ( ) 2
According to this list return_var code 2 means
Incorrect use of embedded shells (as per Bash documentation)
But what exactly does this mean? The command mocp --helpworks both in the console and in PHP exec. How to run mocp with each parameter in PHP?
EDIT:
I just logged in as "www-data" (Apache user) and tried to execute mocp commands. I received this return:
FATAL_ERROR: unable to create directory /var/www/.moc
.moc Pi www-data ( "pi" ):
sudo cp /home/pi/.moc/ /var/www/.moc
script :
... Array ([0] = > ... [1] = > ...) 2
. www-data mocp -S
FATAL_ERROR: ()
2:
permsions /var/www/.moc. mocp -S,
...
...
ALSA...
ALSA lib confmisc.c: 768: (parse_card) '0'
ALSA lib conf.c: 4241: (_ snd_config_evaluate) snd_func_card_driver : Datei oder Verzeichnis nicht gefunden
ALSA lib confmisc.c: 392: (snd_func_concat) ,
ALSA lib conf.c: 4241: (_ snd_config_evaluate) snd_func_concat : Datei oder Verzeichnis nicht gefunden
ALSA lib confmisc.c: 1251: (snd_func_refer)
ALSA lib conf.c: 4241: (_ snd_config_evaluate) snd_func_refer : Datei oder Verzeichnis nicht gefunden
ALSA lib conf.c: 4720: (snd_config_expand) : Datei oder Verzeichnis nicht gefunden
ALSA lib pcm.c: 2217: (snd_pcm_open_noupdate) PCM
OSS...
FATAL_ERROR: !
FATAL_ERROR: !