I am working on a minecraft control panel in Ubuntu and thus I need to start/stop a .jar filewith shell_exec();

When I try commands like "whoami", the output is normal. But when I try this:

shell_exec("screen -dmS mcsrv java -Xmx512M -jar /var/www/srv/craftbukkit.jar -o true nogui");

It does not do anything, I have checked the permissions too and www-data is the owner of the files

有帮助吗?

解决方案

Try to redirect the standard error stream to stdout (by appending 2>&1 to the command), fetch that output and print it to check whether there was a meaningful error message

$cmd = "screen -dmS mcsrv java -Xmx512M -jar /var/www/srv/craftbukkit.jar -o true nogui";
$redirect = '2>&1';
// using variable substitution only for readability here 
shell_exec("$cmd $redirect", $output);
var_dump($output);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top