467,861 Members | 1,696 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,861 developers. It's quick & easy.

Speeding up command line scripts

Hi.
I have a command line script which works really fine, the only problem
is that it take *really* long for the first output to be printed on
screen.
Since I also get some HTTP headers I'm suspecting that some sort of
output buffering is used.
How can I tell PHP to flush the buffer automatically (without using
flush(); after every print or echo) and to remove the headers?

Jul 17 '05 #1
  • viewed: 2471
Share:
4 Replies
"Snyke" wrote:
Hi.
I have a command line script which works really fine, the only problem is that it take *really* long for the first output to be printed on
screen.
Since I also get some HTTP headers Iím suspecting that some sort
of
output buffering is used.
How can I tell PHP to flush the buffer automatically (without using
flush(); after every print or echo) and to remove the headers?


Snyke, why do you have http headers in command line php. It is not
needed. At a minimum, you can put in some conditional statements to
take them out if running from command line (there are ways to
auto-detect running from command line vs. from browser).

Once that is done, it is much easier to isolate the problem.

By the way, I have a ton of command line php code, and never seen this
problem, so I suspect something is going on before the first echo...
you may want to take out the code, or put in some timing echo
statements.

steve

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Speeding...ict136881.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=457262
Jul 17 '05 #2
Snyke wrote:
Hi.
I have a command line script which works really fine, the only problem
is that it take *really* long for the first output to be printed on
screen.
Since I also get some HTTP headers I'm suspecting that some sort of
output buffering is used.
How can I tell PHP to flush the buffer automatically (without using
flush(); after every print or echo) and to remove the headers?


You can disable outputbuffering in the php.ini file (output_buffering = off)
and also specify if you want php to flush each time an echo or print is
encountered.(implicit_flush = on)

But It sounds like something else is 'wrong' if it takes that long...
HTH
Pjotr
Jul 17 '05 #3
Snyke wrote:
Hi.
I have a command line script which works really fine, the only problem
is that it take *really* long for the first output to be printed on
screen.
Since I also get some HTTP headers I'm suspecting that some sort of
output buffering is used.
How can I tell PHP to flush the buffer automatically (without using
flush(); after every print or echo) and to remove the headers?


to tell php to omit the headers:
php -q script.php
or if you've got an embedded interpreter directive:
#!/usr/bin/php -q

or if you're still using Microsoft Operating systems:
php.exe -q script.php

to flush the output,
flush();

(note this will only flush up to the last newline char)

HTH

C.
Jul 17 '05 #4
"Colin McKinnon" <co**************@andthis.mms3.com> wrote in message
news:ce*******************@news.demon.co.uk...
Snyke wrote:
Hi.
I have a command line script which works really fine, the only problem
is that it take *really* long for the first output to be printed on
screen.
Since I also get some HTTP headers I'm suspecting that some sort of
output buffering is used.
How can I tell PHP to flush the buffer automatically (without using
flush(); after every print or echo) and to remove the headers?


to tell php to omit the headers:
php -q script.php
or if you've got an embedded interpreter directive:
#!/usr/bin/php -q

or if you're still using Microsoft Operating systems:
php.exe -q script.php

to flush the output,
flush();

(note this will only flush up to the last newline char)

HTH

C.


Just throw an 'ob_end_flush();' at the start of your script... NOT after
every echo or print.

Norm
--
Avatar hosting at www.easyavatar.com
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ever Olano | last post: by
6 posts views Thread by jonathan | last post: by
9 posts views Thread by Toralf Kirsten | last post: by
4 posts views Thread by Mark | last post: by
reply views Thread by CatrinaJones | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.