Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post

    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 09:47 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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();"

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post
    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-28-2005 at 12:15 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •