Hallo,
ich versuche mit den funktionen system oder exec einige shell scripte unter Linux auszuführen, bisher ohne erfolg:
Ich habe die anweisungen auf php.net befolgt und simple sachen wie ls gehen auch, aber wie ich genau aktionen als root ausführe ist mir nicht klar.
hier mal mein code:
<? function start_ccx() { $cmd = "sudo /tmp/ccxstream.sh start" ; system("$cmd 2>&1"); } function stop_ccx() { $cmd = "killall -9 ccxstream" ; system("$cmd 2>&1"); } function inputbox ($name, $type, $value = "", $size = "", $maxlength = "") { if ($value == "") { eval ("global \$_POST;"); eval ("\$value=\$_POST['$name'];"); } echo "<input name=\"$name\" type=\"$type\" value=\"$value\" size=\"$size\" maxlength=\"$maxlength\">"; } ?> <table align='center' class='tblframeline' width=100%> <tr> <td class='ueberschrift' >CCX Streaming Server</td> </tr> <tr> <td > <table align=center width='100%' cellSpacing='1' cellPadding='15' border='0'> <tr> <td> CCX läuft <? //test $cmd = "sudo /tmp/ccxstream.sh start" ; system("$cmd 2>&1"); ?> </td> </tr> <tr > <td> <div align="left"> <form method="post" action="<? start_ccx(); ?>"> <? inputbox ("Abschicken", "submit", "Starten"); ?> </form> </div> <div align="left"> <form method="post" action="<? stop_ccx(); ?>"> <? inputbox ("Abschicken", "submit", "Stopen"); ?> </form> </div> </td> </tr> </table> </td> </tr> </table>
Da mit den scripts dienste gestartet werden müssen diese als root ausgeführt werden, kann man evtl durch sudo tricksereien diese bestimmten scripte durch anderen user starten lassen?
danke