PHP shell_exec() won't execute screen command to run .jar file

心不动则不痛 提交于 2019-12-11 09:17:54

问题


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


回答1:


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);


来源:https://stackoverflow.com/questions/22754443/php-shell-exec-wont-execute-screen-command-to-run-jar-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!