...

View Full Version : exec() Page never loads



tsclan
04-27-2005, 09:41 PM
I have this current small code which will execute a .sh file depending what button was pressed:

<?PHP
if(isset($_POST['restartbot'])) {
echo 'Bot restarted';
chdir('/home/rtcw/wab-1.0a');
exec("./wab-restartwab.sh", $output);
echo $output;
exit();
}
if(isset($_POST['restartserver'])) {
echo 'Server Restarted';
chdir('/home/rtcw/wab-1.0a');
shell_exec("./wab-restartwolf.sh");
}

?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method = "post">
<input type="Submit" name="restartbot" value="Restart Bot"><br />
<input type="Submit" name="restartserver" value="Restart Server">
</form>

Now this does work and it does restart the server and bot when i press the button, so the files are being executed. Although when I press the button the page just loads and never actaully displays any of the text I want it to echo. Instead the loading bar on IE just slowly crawls along even though the command has been exacuted it still doesnt load the page.
In Firefox when I click on a button it does display the text in the echo but the loading bar stops halfway and says "Transfering Data From xxx.xxx.xxx.xxx:"

I have no idea whats causing the page not to load even though the exec has been done. So any help or ideas on this would be great
Thanks

Velox Letum
04-27-2005, 11:23 PM
Its probably executing the script before the server can make a connection and send the page to you. You might implement a delay?

tsclan
04-27-2005, 11:56 PM
Ok so where exactly do I put the delay?
I Take ill be using the sleep function for delaying it
e.g "sleep(10);"
But would that be before or after the exec ?

But thanks for your Idea



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum