Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-27-2005, 08:41 PM   PM User | #1
tsclan
Regular Coder

 
Join Date: Aug 2003
Location: scotland, edinburgh
Posts: 176
Thanks: 5
Thanked 1 Time in 1 Post
tsclan is an unknown quantity at this point
exec() Page never loads

I have this current small code which will execute a .sh file depending what button was pressed:
PHP Code:
<?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

Last edited by tsclan; 04-27-2005 at 08:47 PM..
tsclan is offline   Reply With Quote
Old 04-27-2005, 10:23 PM   PM User | #2
Velox Letum
Senior Coder

 
Join Date: Apr 2005
Location: Colorado, United States
Posts: 1,208
Thanks: 0
Thanked 0 Times in 0 Posts
Velox Letum is an unknown quantity at this point
Its probably executing the script before the server can make a connection and send the page to you. You might implement a delay?
__________________
"$question = ( to() ) ? be() : ~be();"
Velox Letum is offline   Reply With Quote
Old 04-27-2005, 10:56 PM   PM User | #3
tsclan
Regular Coder

 
Join Date: Aug 2003
Location: scotland, edinburgh
Posts: 176
Thanks: 5
Thanked 1 Time in 1 Post
tsclan is an unknown quantity at this point
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

Last edited by tsclan; 04-27-2005 at 11:15 PM..
tsclan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:02 AM.


Advertisement
Log in to turn off these ads.