Jump to content

Help with passthru() or exec()


Illuminati

Recommended Posts

I am trying to make a website where I can restart an application. I can make it terminate the app but it hangs when trying to restart it.

 

the website calls the function this way:

 

#####################
PHP
#####################
<?php
if (isset($_POST["kill_server"])){
  kill_server();
  echo "<img src=./images/ok.gif> El server esta siendo apagado. Por favor espere 1 minuto!";
} elseif (isset($_POST["init_server"])){
  init_server();
  echo "<img src=./images/ok.gif> El server esta siendo iniciado. Por favor espere 3 minutos!";
}
?>

#####################
HTML
#####################
<form action="" method="post" name="kill_server" id="restart_server">
  <input type="submit" name="kill_server" value="Kill Server">
</form>
<form action="" method="post" name="init_server" id="restart_server">
  <input type="submit" name="init_server" value="Init Server">
</form>

The functions being called are these:

 

<?php
function kill_server (){
    require("includes/log_functions.php");
    $logfile = "logs/server_kill.php";
    writelog::writelog_server_kill($logfile);
    passthru("c:\scripts\kill.bat");

}
function init_server (){
    require("includes/log_functions.php");
    $logfile = "logs/server_init.php";
    writelog::writelog_server_init($logfile);
    passthru("notepad");

}
?>

 

The first function works just fine, but the second one hangs. The batch file just calls for notepad.exe so it's nothing big.

 

Any help is greatly appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/42443-help-with-passthru-or-exec/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.