ID:               30794
 Comment by:       mvel at centrum dot cz
 Reported By:      stolle at web dot de
 Status:           Open
 Bug Type:         Program Execution
 Operating System: Windows XP SP2
 PHP Version:      5.0.2
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[2004-11-19 10:53:49] stolle at web dot de

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 ???

------------------------------------------------------------------------

[2004-11-15 21:43:16] stolle at web dot de

Reopened

------------------------------------------------------------------------

[2004-11-15 21:42:13] stolle at web dot de

It seems to be so, that PHP wait's for the last process of the group of
child processes to terminate.
Is there any way (in PHP) to break that behavour?

------------------------------------------------------------------------

[2004-11-15 21:36:41] stolle at web dot de

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 ???

------------------------------------------------------------------------

[2004-11-15 16:54:22] [EMAIL PROTECTED]

I don't see any bugs here. It's pretty well expected behaviour.
The docs say: "If you start a program using this function and want to
leave it running in the background, 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."
But your program *waits for your input* (i.e. until you close it), so
PHP will wait for it too, 'cause exec() "returns the last line from the
result of the command" (c).

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/30794

-- 
Edit this bug report at http://bugs.php.net/?id=30794&edit=1

Reply via email to