From: Leonardo on
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.
From: Shawn McKenzie on
On 07/15/2010 10:51 AM, 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';
>
> ?>
>

Try not use the short open tag. Use <?php

--
Thanks!
-Shawn
http://www.spidean.com
From: Leonardo on
Em 15/07/2010 18:19, Shawn McKenzie escreveu:
> On 07/15/2010 10:51 AM, 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';
>>
>> ?>
>>
>
> Try not use the short open tag. Use<?php
>

Bad habit. I know.
From: Shawn McKenzie on
On 07/15/2010 04:40 PM, Leonardo wrote:
>
> Bad habit. I know.

Did it fix it?

--
Thanks!
-Shawn
http://www.spidean.com
From: Leonardo on
Em 15/07/2010 18:54, Shawn McKenzie escreveu:
> On 07/15/2010 04:40 PM, Leonardo wrote:
>>
>> Bad habit. I know.
>
> Did it fix it?
>

Not really. The server allows short open tags. So, nothing changed.