TrueBlue TrueBlue - 12 days ago 8
Linux Question

From PHP a Simple Linux Script to return "Hello World"

Okay, happy to accept down votes to get to the bottom of my problem. I am brand new to Linux but have hosted my PHP based site on a Linux cloud server and need to run a FFMPEG script to convert a video. Under windows I have the full application working but under Linux I can't seem to get a basic script working and was wondering if someone can point me in the right direction. I have read the myriad posts on this, for example, Run bash Command from PHP but it does not help me get to the bottom of it.

Here is what I have so far.

$old_path = getcwd();
chdir('videos/');
$new_path = getcwd();
echo('newpath '.$new_path); <-- this outputs 'old_path/videos'
$temp= shell_exec('./testScript.sh');
echo ($temp) <-- produces nothing


Test script testScript.sh is in the video directory and is simply

echo "hello world"


Thanks...

Answer

In shell script must write and the interpretator.

Try this: shell_exec('php ./testScript.sh');

Edit: change php with correct interpretator (bash, sh...)