0

today I started a project that will analyze tracks I have and add a BPM tag to each song inside of a mysql table. Everything was going well untill I was doing my finishing steps: shell_exec-ing my command in ubuntu...

    $command='/usr/bin/bpm-tag -f -n "/var/www/website/music/music.mp3"';
    echo shell_exec($command);

This was my command/ code and it doesnt work...(it didnt output anything, when I run the same command using putty I get what I need...)

$output=  shell_exec('whoami');

print_r($output);

Outputs:

www-data
7
  • Observe that the user www-data may not have the rights to either run this command or modify the files envolved.
    – Havenard
    Jul 25, 2014 at 19:18
  • Also, shell_exec() will only return the program's stdout. Perhaps what you see in PuTTY is the program's stderr. Try using $command = '/command ... 2>&1';
    – Havenard
    Jul 25, 2014 at 19:22
  • oh thanks! 2>&1 this realy worked! what does 2>&1 do? I dont understand THANKS!! Jul 25, 2014 at 19:32
  • It dumps stderr onto stdout so those applications that only read stdout receive stderr too the same way the console does.
    – Havenard
    Jul 25, 2014 at 19:34
  • Another way to do that is to use proc_open() that allows you to take separate descriptors for each "pipe".
    – Havenard
    Jul 25, 2014 at 19:35

0

Your Answer

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

Browse other questions tagged or ask your own question.