0

Im making a webscript starting a minecraft server and i have a problem with shell_exec executing command on screen:

$output = shell_exec('screen -d -m -S ServerOne');    
$output2 = shell_exec('screen -S ServerOne -p 0 -X stuff "cd /var/www/html/servers/asd/ && java -Xmx1024M -Xms1024M -jar server.jar nogui > /screenlog ^M"');

It creates a screen with name ServerOne but didnt happened nothing after it! I want to execute on it:

cd /var/www/html/servers/asd/ && java -Xmx1024M -Xms1024M -jar server.jar nogui > /screenlog ^M

I tried a lot of things and nothing worked, please help! :)

Sorry for my bad English.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • Can't you juste make a shell script launching those two commands ? – smwhr Jul 10 '20 at 20:30
  • I want to make a controll panel for my server(webpage). – Dávid Barič Jul 10 '20 at 20:36
  • You'd be better off just reading the content of `screenlog` as a stream (see https://stackoverflow.com/questions/3218895/php-how-to-read-a-file-live-that-is-constantly-being-written-to) that way you'll be monitoring without risk of crashing the minecraft server because of a php error. – smwhr Jul 10 '20 at 20:43
  • But the server didnt start and i dont see any errors. – Dávid Barič Jul 10 '20 at 20:59

0 Answers0