I'm using this code to send command via RCON to a game server, with this library.
This is my actual code:
<?php
require __DIR__ . 'SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
define( 'SQ_SERVER_ADDR', 'my ip' );
define( 'SQ_SERVER_PORT', 27015 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );
$Query = new SourceQuery( );
try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
$Query->SetRconPassword( 'my pass' );
var_dump( $Query->Rcon( 'the command' ) );
{
$Query->Disconnect( );
}
?>
But for example if I want to stop the server I can just send the command "quit" through rcon, but how about starting the server? My idea was that I can send this command once I press a button (the server is on the same machine as the website), but with this piece of code it does not work:
exec('screen -p 0 -S csgo -X eval \'stuff "./scds_run other parameters"\\015\' ');