473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

command-line PHP and suppressing headers - help

How do I suppress the lines PHP normally delivers to stdout (your browser)
if I am doing command-line PHP?

e.g.

stuff.php:

<? echo 'Hello World'; ?>

Calling it from a Red Hat 7.3 command-line terminal I would do the
following:

php /my/directory/path/to/stuff.php

And I would eventually get

Hello World

But before that, an enormous amount of garbage, particularly HTTP header
information:

PHP Version 4.2.3
Content-type: text/html
Hello World

How do I strip everything out except that which I need to see while using
PHP from the command line? I am having a horrific time using TCL instead.

Thanx
Phil
Jul 17 '05 #1
5 9782
Phil Powell <so*****@erols.com> wrote:
How do I suppress the lines PHP normally delivers to stdout (your browser)
if I am doing command-line PHP?


$ php -h
Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-f <file> Parse <file>. Implies `-q'
-v Version number
-C Do not chdir to the script's directory
-c <path> Look for php.ini file in this directory
-a Run interactively
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-z <file> Load Zend extension <file>.
-l Syntax check only (lint)
-m Show compiled in modules
-i PHP information
-h This help

(or something really similar depending on php version (4.1.2 above))

--

Daniel Tryba

Jul 17 '05 #2

"Phil Powell" <so*****@erols.com> wrote in message
news:16oJb.62427$hf1.41608@lakeread06...
How do I suppress the lines PHP normally delivers to stdout
(your browser) if I am doing command-line PHP?

e.g.

stuff.php:

<? echo 'Hello World'; ?>

Calling it from a Red Hat 7.3 command-line terminal I would
do the following:

php /my/directory/path/to/stuff.php

And I would eventually get

Hello World

But before that, an enormous amount of garbage, particularly
HTTP header information:

PHP Version 4.2.3
Content-type: text/html
Hello World

Your're using the CGI-version, rather than the CLI-version binary, from the
command-line.

How do I strip everything out except that which I need to see while using
PHP from the command line? I am having a horrific time using TCL instead.


Relevant information may be obtained from:

http://php.net/manual/en/features.commandline.php

I hope this helps.

Anthony Borla
Jul 17 '05 #3
Daniel Tryba <ne****************@canopus.nl> wrote in message news:<bt**********@news.tue.nl>...
Phil Powell <so*****@erols.com> wrote:
How do I suppress the lines PHP normally delivers to stdout (your browser)
if I am doing command-line PHP?


$ php -h
Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-f <file> Parse <file>. Implies `-q'
-v Version number
-C Do not chdir to the script's directory
-c <path> Look for php.ini file in this directory
-a Run interactively
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-z <file> Load Zend extension <file>.
-l Syntax check only (lint)
-m Show compiled in modules
-i PHP information
-h This help

(or something really similar depending on php version (4.1.2 above))


php -q does the exact trick,thanx!

Phil
Jul 17 '05 #4
php -q does the exact trick,thanx!

Phil


if you are heavy into cli, you can do this:

make the very first line of your script read:
#!/bin/php -q

then: (note: it does not have to end in .php)
chmod 755 yourscriptname

now your script is executable as a shell script.

put a copy of it in /usr/bin

then when ever you want to use it, just type the name of the script
--
Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #5

"CountScubula" <me@scantek.hotmail.com> wrote in message
news:Od*****************@newssvr25.news.prodigy.co m...
php -q does the exact trick,thanx!

Phil


if you are heavy into cli, you can do this:

make the very first line of your script read:
#!/bin/php -q

then: (note: it does not have to end in .php)
chmod 755 yourscriptname

now your script is executable as a shell script.

put a copy of it in /usr/bin

then when ever you want to use it, just type the name of the script
--
Mike Bradley
http://gzen.myhq.info -- free online php tools


Thanx I'll have to remember that too!

Phil
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sveta | last post by:
Hi, all! I am new with J2ME. I have application that has form with 2 commands (exit and select). All UI uses are high level API, and it is very important to leave it high-level. This...
2
by: mksql | last post by:
New to Tkinter. Initially, I had some code that was executing button commands at creation, rather than waiting for user action. Some research here gave me a solution, but I am not sure why the...
2
by: Paul A. Wilson | last post by:
I'm new to Tkinter programming and am having trouble creating a reusable button bar... I want to be able to feed my class a dictionary of button names and function names, which the class will make....
1
by: TEK | last post by:
Hello I'm wondering if anyone out there might give some input/suggestions/viewpoints around the Command pattern. In my case, the number one priority for using the pattern is undo support. Some...
8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
8
by: Charles Law | last post by:
I am implementing the command pattern in VB.NET, where the commands have been serialised. That is, I have several classes that all inherit from my base Command class, that implements ICommand...
4
by: FluffyCat | last post by:
New on November 29, 2005 for www.FluffyCat.com PHP 5 Design Pattern Examples - the Command Pattern. Since you all enjoyed the Visitor Pattern so much yesterday, today I have the Command Pattern...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.