|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-11-15 14:47 UTC] stolle at web dot de
Description:
------------
I'm using PHP on Apache2 (both: Latest Builds)
When starting a Program using "exec()" die PHP-Scripts allways hangs under Windows, until the started program terminates.
There is no chance to start f.e. notepad.exe in that way, that notepad runs interaktivly, but PHP continous work.
Notepad is just an example, i want to control (start and stop) some Windows-Tasks throug PHP.
I tried the latest PHP snapshot-Version as well.
Reproduce code:
---------------
exec('notepad.exe');
exec( "cmd.exe /c c:/windows/notepad.exe 2>nul: >nul:" );
exec( "c:/windows/notepad.exe 2>nul: >nul: &" );
exec( "c:/windows/notepad.exe 2>nul: >nul:" );
Expected result:
----------------
PHP Script should NOT wait for end of notepad
Actual result:
--------------
PHP Script wait's for end of notepad
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 22:00:01 2025 UTC |
you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends." So the right question may be: How do i redirect the standardoutput under Windows, so that PHP do NOT wait fpr the end of the Programm. I tried som more lines: exec( "cmd.exe /c start c:/windows/notepad.exe <nul: 2>nul: >nul:" ); exec( "c:/windows/notepad.exe <nul: 2>nul: >nul:" ); It's always the same: PHP always wait's for notepad's end. BUT I DONT WANT TO WAIT! What do i have to do (under windows) to not wait for the end of the program ???So the right question may be: How do i redirect the standardoutput under Windows, so that PHP does NOT wait for the end of the Programm. I tried some more lines: exec( "cmd.exe /c start c:/windows/notepad.exe <nul: 2>nul: >nul:" ); exec( "c:/windows/notepad.exe <nul: 2>nul: >nul:" ); It's always the same: PHP always wait's for notepad's end. BUT I DON'T WANT TO WAIT! What do i have to do (under windows) to not wait for the end of the program ???Hi, I was the same problem. No one of these below has effect. Like my English :-). exec('cmd /C "ping 147.32.x.x -t"'); exec('cmd /C "start ping 147.32.x.x -t"'); exec('cmd /C "pingIP.bat"'); exec('cmd /C "start pingIP.bat"'); content of pingIP.bat ping 147.32.x.x -t or cmd /c 147.32.x.x -t or cmd /c 147.32.x.x -t so <?php $fp=popen("start InstallLinux.exe","r"); pclose($fp); echo "Hastalavista Gates"; ?> Why "r" and not "w"? I dont know. "r" was in the manual. I think, it is much of a muchness. wella