Ok, so I ran
su www-data -c "php /var/www/openmediavault/yle_dl.php"
however the terminal became unresponsive and no output was printed. After a couple of minutes I noticed in the WebGui that my cpu and ram usage was sky rocketing so I killed the ssh session and rebooted my OMV box. Once it came back up I logged back in over ssh and had a look at my media folder, and it had indeed started donwloading the video however it was not finished although it had been running much longer than it usually takes to download a video.
I then started wondering, should it not be
su openmediavault -c "php /var/www/openmediavault/yle_dl.php"
(echoing whoami in the php script also gave openmediavault when executing from a web browser)? I tried that and the script executed nicely in a minute or so, video downloaded and converted. So two things. The correct user was openmediavault rather than www-data, right? And why did the cpu and ram usage sky rocket when trying to run the script as www-data?
Also since the
su openmediavault -c "php /var/www/openmediavault/yle_dl.php"
executed the script without errors I guess that this cannot be a permission issue. So, I changed the yle-dl command in the script to:
$test = shell_exec("yle-dl $url -o /path/to/my/media/folder/video_temp.flv 2>&1");
echo "<pre>$test</pre>";
After that I visited the yle_dl.php page in a web browser and got this output:
Traceback (most recent call last):
File "/usr/local/bin/yle-dl", line 1653, in
main()
File "/usr/local/bin/yle-dl", line 1622, in main
rtmpdump_binary = which('rtmpdump')
File "/usr/local/bin/yle-dl", line 227, in which
for path in os.environ["PATH"].split(os.pathsep):
File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'PATH'
So, it seems like "the script is run differently" depending on if it is execute remotely (visiting the ip_to_my_omv_box/yle_dl.php) or if it is run locally (su openmediavault)?