Error on popen()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Netherfox
Forum Newbie
Posts: 6
Joined: Tue Jan 15, 2008 12:32 pm

Error on popen()

Post 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)?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Error on popen()

Post by requinix »

start is not an application. It's a command supported by cmd.exe.
Netherfox
Forum Newbie
Posts: 6
Joined: Tue Jan 15, 2008 12:32 pm

Re: Error on popen()

Post 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...
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Error on popen()

Post 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.
Post Reply