Leonardo wrote:
> Hi everybody. I need to use exec() to run a background php script, but
> it's not working properly. Take a look at this sample:
> 
> a.php
>    <?
> 
>    echo ' File A (1) ';
> 
>    exec('php b.php > output.txt &');
> 
>    echo ' File A (2) ';
> 
>    ?>
> 
> b.php
>    <?
> 
>    echo 'File B';
> 
>    ?>
> 
> output.txt (begins with 64 null bytes before the following)
>     File A (2)
> 
> I would expect the output's content to be "File B", but it's not
> happening. I came across this problem because I have a mailing
> application which stopped working after being moved to a new host. The
> messages were sent by a background script launched on user's demand.
> Like this:
> 
> SendMessages.php
>    <?
>       ...
>       exec('php Daemon.php -x ' . $USERID . ' > /dev/null &');
>       ...
>    ?>
> 
> Now it won't work, and I got no clue about what's going on. What now?
> 
> Thank you.
> 

I tried running the same script, and found that the php binary is not in my 
path.

run this

echo passthru('which php');

Also, modify your existing exec() command to the following and it will capture
errors too.

exec('php b.php > output.txt 2>&1 &');

After running this is when I noticed it say "sh: php: not found"



-- 
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to