Forum

> > Off Topic > SSH2 doesn't start server
Forums overviewOff Topic overviewLog in to reply

English SSH2 doesn't start server

3 replies
To the start Previous 1 Next To the start

old SSH2 doesn't start server

Marcell
Super User Off Offline

Quote
Hello,


I trying to modificate the server start script with no luck.

The connection works fine, i tested, but whenever i try to start the server it's not working

1
2
3
4
5
6
7
8
9
10
11
12
13
function StartServer($id) {
$query = mysql_query("SELECT * FROM `cm_servers` WHERE ID = '".mysql_real_escape_string($id)."' LIMIT 1") or die(mysql_error());
	if(mysql_num_rows($query) == 0) {
		echo "<button class='btn btn-block btn-danger btn-xs'>Server couldn't start.</button><meta http-equiv='refresh' content='3; url=servers.php' /><br />";
	} else {
		while($srv = mysql_fetch_assoc($query))
		$connection = ssh2_connect('127.0.0.1', 22);
		ssh2_auth_password($connection, 'user', 'pass');
		$stream = ssh2_exec($connection, "nohup ./cs2d_dedicated -name '".$srv['name']."' -maxplayers ".$srv['maxplayers']." -port ".$srv['port']." -rcon '".$srv['rcon']."' >/dev/null 2>&1 & echo $! > ./_servers/pid_".$srv['ID'].".pid");
		}
		echo "<button class='btn btn-block btn-success btn-xs'>Server has been started successfully.</button><meta http-equiv='refresh' content='3; url=servers.php' /><br />";
	
}

idea?

// please dont tell me use pdo, i will use it, but first i would like to test with mysql.

old Re: SSH2 doesn't start server

Hajt
User Off Offline

Quote
Try
1
2
3
4
5
6
$name = $srv['name'];
$maxplayers = $srv['maxplayers'];
$port = $srv['port'];
$rcon = $srv['rcon'];
$id = $srv['ID'];
$stream = ssh2_exec($connection, "nohup ./cs2d_dedicated -name $name -maxplayers $maxplayers -port $port -rcon $rcon >/dev/null 2>&1 & echo $! > ./_servers/pid_$id.pid");
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview