Klyx99 Posted May 15, 2020 Share Posted May 15, 2020 (edited) I have two functions that execute an exe program (personal project for a minecraft back end.) Windows only. First one will execute the sending of commands (THIS ONE WORKS) /* check to see if admin is sending commands to terminal via web */ if(isset($_POST['command'])) { $content = $_POST['command']; writeMCCommandTxt($content); try { exec(SERVER_DIR.'mcCommand.exe',$output); } catch ( Exception $e ) { die ($e->getMessage()); } }// END COMMAND ENTRY This has been a head scratcher for most the week - any help or suggestions would be great!! thanks!! HTML <div id="commands"> <div id="command_input"> <form method="post" id="commandForm" action="index.php"> <label for="command" >Console Command:</label><br/> <input type="text" name="command" autofocuS/> <input type="submit" name="submit_command" value=" >> " /> <input type="button" value="Refresh page" onclick="location.reload(true);" /> </form> </div> </div> This is used to start the server // STARTING SERVER if(isset($_POST['startServerBtn'])){ try { exec(SERVER_DIR.'startServer.bat 2>&1' ,$output); } catch( Exception $e ) { die ($e->getMessage()); } } HTML <div id="server_control"> <ul> <li> <form action="index.php" method="post"> <input type="submit" value="START" id="startServerBtn" name="startServerBtn"/> </form> </li> </ul> </div> MCCOMMANDS.EXE will work from both browser(php) and file manager(tested) the STARTSERVER.EXE will NOT work from browser(php), but will work from file manager The function IS being accessed - debug is showing it going there, and it seems to be running Both exe's are in the same folder Edited May 15, 2020 by Klyx99 code tags missing Quote Link to comment Share on other sites More sharing options...
Klyx99 Posted May 15, 2020 Author Share Posted May 15, 2020 O programmer err - script above is fine. My server was lagging and was able to see if "flash" up and disappear. Apparently there is an issue with the batchfile - paths need to be absolute, The script has it relative, thus why it works from file manager, but not the browser. I'll leave the code up for anyone that wants to make something similar as reference. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.