Page 1 of 1

Starting EXE file using exec()

Posted: Wed Jan 25, 2006 11:32 pm
by Trenchant
I'm working on a game server control panel(windows based). I have everything done except one last part. I am stuck when it comes to actually starting the server. Here's what the mini control panel looks like so far:

http://24.72.116.210/servermanager/index.php?id=1
SAP: 123456

If you click "start server" thats where I'm running into the problem. It says the server is starting but it actually isn't. I checked the server processes and the process of the server isn't running. This is on a dedicated windows box.

I was advised that php isn't the best for this usage but the client I'm working with wants something to get working temporarily. This is the last strand until they can start testing the product in BETA stages. They already have a few clients willing to go onto it understanding that its just a BETA.

Here is the code:

Code: Select all

// Now start the file.
	echo $exe_location;
	$start_game = exec($exe_location, $error);
	
	// Check to see if the game started okay.
	if ($start_game == 0) {
	
		echo "Your server was successfully started.";
		
	}else{ 
	
		echo "There was a problem and your server could not be started.";
		
	}

Posted: Thu Jan 26, 2006 3:29 am
by Jenk
Try using:

Code: Select all

exec($exe_location, $error, $return);

if ($return == 0) {
    echo 'Server started fine';
} else { 
    echo 'Server not started';
}
That might get the "check if it ran" working, but it won't solve your problem of the server not running.

Has the PHP/Apache servers got access to the file? You normally find that the service providers don't like to let these things execute external programs.. it's a bit of a security nightmare at times.

Posted: Thu Jan 26, 2006 11:44 am
by Trenchant
Jenk wrote:Try using:

Code: Select all

exec($exe_location, $error, $return);

if ($return == 0) {
    echo 'Server started fine';
} else { 
    echo 'Server not started';
}
That might get the "check if it ran" working, but it won't solve your problem of the server not running.

Has the PHP/Apache servers got access to the file? You normally find that the service providers don't like to let these things execute external programs.. it's a bit of a security nightmare at times.
No apache doesn't have access to the file. That might be the problem. I will check that as soon as I get access to the server.

Posted: Thu Jan 26, 2006 1:42 pm
by Trenchant
I moved the server files(including exe file) into a folder where apache has dirrect access. It still doesn't want to start up. Now its actually saying it isn't starting though.

When I try to echo the $error variable it just returns array

Posted: Thu Jan 26, 2006 4:02 pm
by feyd

Code: Select all

exec($exe_location, $output, $return);

var_dump($output,$return);

Posted: Thu Jan 26, 2006 4:42 pm
by Trenchant
doesn't display anything more. Just this:

int(1) array(0) { }

int(1) is the $return variable.

Posted: Sun Jan 29, 2006 6:42 pm
by Trenchant
Anyone know what might be the problem?