Jump to content

Executing a program remotely with PHP


sw0o0sh

Recommended Posts

Hi, passthru() seems to not be working anymore for this, but this is what I need done...

 

I need to be able to make the user be able to click a button, which then launches a batch file on my computer.. But passthru() doesnt do the job anymore. And is faulty.. My computer is the server, so it'd also be nice if the command could launch it in a windowed form instead of a background process :-\

 

Here's my code.

 

<?PHP
if($_POST['shutdown']){
$command = 'cmd\stop.bat';
passthru($command);
} else if($_POST['on']){
$command = '..\..\GSV001\run.bat';
passthru($command);

}

?>


<form method='post'>

<input type='submit' name='shutdown' value='Shutdown' /> 
<input type='submit' name='on' value='Turn On' />

</form>

 

"On", for example.. Launches a CMD but the server never turns on. Here's the batch content within it:

 

@echo off
ant run
pause

 

But yeah, that's basically it. Is there any function in PHP that works better than passthru()?

 

Link to comment
https://forums.phpfreaks.com/topic/54891-executing-a-program-remotely-with-php/
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.