Page 1 of 1

php system command not showing window from Apache

PostPosted: 14. April 2011 19:25
by sll1966
Windows7, XAMPP 1.7.3, Apache running as limited user "Apache"

When i run from command line
php test.php
which has
<?PHP
$cmd = "C:\\xampp\\htdocs\AceWeb\\BatFiles\\AceNet\\LoadInvoicesIntoBMCWEB.BAT";
$rc = system("start $cmd");
?>

The CLI window opens up, allows me to interact with it for some user input, then when it exits, returns me to the calling CLI window.

From a browser
It starts a CMD.EXE (i can see it show up in Task Manager), but i can't get to it. Browser hangs waiting till i end the process with Task Manager.

How can i properly have a web user launch this interactive bat file?

Thanks for any help,
Steve

Re: php system command not showing window from Apache

PostPosted: 15. April 2011 15:34
by peterwt
If I understand your posting - you want to run the interactive bat file and get the remote used to respond to some choices. This will not happen as the system call in your php script will open a command window on your PC and execute the bat file. The remote user will see nothing in their browser window as nothing is being directed to it.

If you replace your bat file with one containing the code below you will see a command window open with the results of the DIR command and you will see nothing in the browser window. The choice is just to create a delay.

Code: Select all
Dir C:\
CHOICE /T 10 /C ync /CS /D y



I thing you would be better advised to write the whole in the php - carry out the commands you have in the bat file in php code.

If you leave out the start in your php code so the line becomes $rc = system("$cmd"); you will see the bat file output directed into the browser window but I can see no way to get user input this way.