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? 4 2705
"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
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_bufferi ng = off)
and also specify if you want php to flush each time an echo or print is
encountered.(im plicit_flush = on)
But It sounds like something else is 'wrong' if it takes that long...
HTH
Pjotr
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.
"Colin McKinnon" <co************ **@andthis.mms3 .com> wrote in message
news:ce******** ***********@new s.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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert |
last post by:
I am using the php4-cgi Debian package which is based on PHP 4.3.4.
I have problems when running php4 on the command line. If I say something
like
$ php4 index.cgi
a number of variables are not initialized. For example, $HTTP_GET_VARS is
not set. To get it set, here's my workaround:
|
by: Ever Olano |
last post by:
Hi. In the docs, it says the command-line executable (that allows you to
run PHP scripts on your console as opposed to inside the web server) was
introduced in 4.3.0. But I was told by someone that he can do command-line
stuff with 4.1.0.
Is anyone else using the command-line executable with a version earlier than
4.3.0?
Thanks!
|
by: jonathan |
last post by:
everyone,
I'd like to be able to debug php scripts on the command line, going
through the
browser. In other words, set up the debugger to listen and then type
in a url and have the code stop before displaying stuff to the
browser. Then, step through each individual piece of code, etc, whilst
having the output mirrored to either another file or the debugger
screen...
|
by: Peter A. Schott |
last post by:
Per subject - I realize I can copy/paste a line at a time into an interactive
session when I'm trying to debug, but was wondering if there is any tool out
there that allows me to copy sections of working Python scripts to paste into my
interactive console and let those run so I don't have to copy line-by-line.
Not sure if iPython would meet that criteria or not or even if such a beast
exists. It would be helpful for debugging some of my...
|
by: Toralf Kirsten |
last post by:
Hi,
we installed db2 v8.1 on red hat linux 9.
Unfortunately, the backspace and the delete button doesn't work in the
right way. Instead of deleting chars, control characters are inputed.
That makes it very hard to input sql commands at the db2 command line
prompt.
For example: DB2> connect to aDatabase^?^?^?^?^[[3~^[[3~^[[3~
Is there the possibility to set an option / parameter anywhere?
Thanks, Toralf
| |
by: Mark |
last post by:
Hello,
I'm trying to install an ASP.Net project using the command line (SDK tools
& perhaps IIS Admin scripts?)
Does anyone know of an automatic, command-line-driven way, to creat the
ASP.Net virtual directory, essentially mimicking whatever VS.Net does when it
creates a web project?
Ideally it would be as simple as "CreateAspWebApp.bat virtualPath
PhysicalPath"
|
by: comp.lang.tcl |
last post by:
The TCL command I am using will do a command-line action on a PHP
script:
set cannotRunPHP
I have to do it this way as both the TCL script and the PHP script run
as CLI. However, "info.php" requires user input to run; this causes
the TCL script calling the PHP script to hose up and die.
Is there a way I can do this so that the TCL script can call the PHP
|
by: code green |
last post by:
What is the best command line equivalent of $_SERVER.
I have recently written a number of scripts to run from an intranet
that generate reports written to CSV and XLS files that can be downloaded.
I have extended these scripts to zip and email the reports to personnel.
I am now trying to automate the scripts by calling them from Windows Scheduled Task using such CLI C:\apache\xampp\php\php.exe ...
|
by: CatrinaJones |
last post by:
Hello guys,
please could someone answer my question? how to run a plpgsql script from
the command line? is possible to run like that? i hava a set of scripts to
run. for example insertion for one table, updation for another table.
otherwise is there any option to save those scripts in a file and through
some command can i execute from the command line? if so, what should be the
extension of file & what is the command to run that file....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |