Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

No ouput until program end, why?

0 views
Skip to first unread message

Jean-Christian Imbeault

unread,
Oct 4, 2002, 12:58:48 AM10/4/02
to php-g...@lists.php.net
I am running a PHP program under Linux on the command line. The problem
I have is that I get no output to the screen until the program finishes.

I have lots of echo statements throughout the program to help me debug
but none of them are printed until the program finishes, which is really
a pain since the prog takes 30 minutes to run ...

The main() looks something like this. Can someone help me figure out why
it is not printing anything until the program exists?

pg_exec($CONN, "BEGIN");
for ($i = 0; $i < 6001; $i++) {
$retval = process($aFields);
if ( ($i % 100) == 0 ) echo "$i\n";
if ($retval == 1) echo "error on line $i \n";
}

echo "COMMIT \n";
pg_exec($CONN, "COMMIT");

Thanks,

Jc

Ernani Joppert Pontes Martins

unread,
Oct 4, 2002, 2:43:51 AM10/4/02
to php-g...@lists.php.net
Have you tried this way ?

php -q your_file.php > /path/to/output_filename


"Jean-Christian Imbeault" <jean_ch...@myrealbox.com> escreveu na
mensagem news:3D9D2008...@myrealbox.com...

Jean-Christian Imbeault

unread,
Oct 4, 2002, 4:00:23 AM10/4/02
to php-g...@lists.php.net
Ernani Joppert Pontes Martins wrote:
> Have you tried this way ?
>
> php -q your_file.php > /path/to/output_filename

How would this help??

All that would do is redirect the output to a file.

My problem is that I want output *before* the program ends ...

Why aren't the echo statements I have in my for loop being printed out
to the screen until the program terminates ??? I should get something
printed out at every 100 lines ... but nothing gets printed until the
end of the program ... At the end I get all the output I should.

But not *before* the program ends ...

Jc

Tim Ward

unread,
Oct 4, 2002, 4:25:46 AM10/4/02
to Jean-Christian Imbeault, php-g...@lists.php.net
does output buffering not work with command line PHP?
http://www.php.net/manual/en/ref.outcontrol.php

Tim Ward
www.chessish.com

Marek Kilimajer

unread,
Oct 4, 2002, 6:32:18 AM10/4/02
to PHP
Try checking the output_buffering option

John W. Holmes

unread,
Oct 4, 2002, 7:20:14 AM10/4/02
to Jean-Christian Imbeault, php-g...@lists.php.net

Take a look at flush(). You may have to play with it to get enough data
in the buffer for flush() to flush it, but hopefully it'll help.

Also, make sure output_buffering is off.

---John Holmes...


0 new messages