For example, when I try to execute
$output=shell_exec('ls -l');
echo "<pre>$output</pre>";
It succesfully prints the output of 'ls -l'.
However, I cannot run a shell script which simply creates a file:
shell_exec('sh /home/ubuntu/Desktop/myScript.sh');
Is it about user access permissions defined in apache?
How can I fix it?
What output do you expect from that script? I shell_exec() will probably only output STDOUT, so if there's errors you will need to redirect them from STDERR like this:
<command> 2>&1
I'm guessing here, but try it with just a simple echo statement in the shell script. See if that works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.