Page 1 of 1

Error on popen()

Posted: Thu Mar 25, 2010 8:47 am
by Netherfox
Hello all,

I'm trying to use the popen() function to run a php thread like this:

Code: Select all

$command_string = "start /b c:\\php\\php.exe c:\\inetpub\\wwwroot\\app_folder\\script.php --arg1=foo --arg2=bar ";
popen($command_string, 'r');
On the popen() line I am receiving an error message that the "file or directory does not exist". I'm not sure what I'm doing wrong here. Could it be permissions? Perhaps it is looking for a path relative to the working directory (not sure what that would be in this case)?

Re: Error on popen()

Posted: Thu Mar 25, 2010 9:12 am
by requinix
start is not an application. It's a command supported by cmd.exe.

Re: Error on popen()

Posted: Thu Mar 25, 2010 9:21 am
by Netherfox
Hmm. well this seems to be how some people are doing it at http://php.net/manual/en/function.popen.php.

I did have similar code working in a separate environment as well...

Re: Error on popen()

Posted: Thu Mar 25, 2010 1:26 pm
by requinix
They may be using an older version of Windows which does have a start.exe binary.

Use popen or perhaps proc_open to run php.exe directly.
Another option is to just include that file directly inside your script. You can set up $argv and $argc to fake a command-line invocation.