php system command not showing window from Apache

Problems with the Windows version of XAMPP, questions, comments, and anything related.

php system command not showing window from Apache

Postby sll1966 » 14. April 2011 19:25

Windows7, XAMPP 1.7.3, Apache running as limited user "Apache"

When i run from command line
php test.php
which has
$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,
Posts: 2
Joined: 14. April 2011 19:14

Re: php system command not showing window from Apache

Postby peterwt » 15. April 2011 15:34

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.
Posts: 42
Joined: 17. March 2009 11:06
Operating System: Windows 7 64 bit Professional

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 39 guests