Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
php via cmdline including unwanted headers
Old
  (#1)
Sebe
Guest
 
Posts: n/a
Default php via cmdline including unwanted headers - 06-02-2007, 07:55 PM

I run some scripts via php (cgi) which sends output to another file, but
it's including unwanted cookie header, etc in the outfile.

example:

php /home/dev/script.php > /home/production/feeds/news.xml 2>&1

and at the top of news.xml i get:

X-Powered-By: PHP/5.2.2
Set-Cookie: .....
Set-Cookie: .....
Cache-Control: private
Content-Type: text/html; charset=ISO-8859-1

i turned off expose php which gets rid of the x-powered-by but what
about the rest?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: php via cmdline including unwanted headers
Old
  (#2)
Martin Mandl - m2m tech support
Guest
 
Posts: n/a
Default Re: php via cmdline including unwanted headers - 06-02-2007, 07:55 PM

On May 30, 8:11 am, sebast...@dslr.net (Sebe) wrote:
> I run some scripts via php (cgi) which sends output to another file, but
> it's including unwanted cookie header, etc in the outfile.
>
> example:
>
> php /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>
> and at the top of news.xml i get:
>
> X-Powered-By: PHP/5.2.2
> Set-Cookie: .....
> Set-Cookie: .....
> Cache-Control: private
> Content-Type: text/html; charset=ISO-8859-1
>
> i turned off expose php which gets rid of the x-powered-by but what
> about the rest?


Try using the 'quiet mode':

php -q /home/dev/script.php > /home/production/feeds/news.xml 2>&1

good luck
Martin

------------------------------------------------
online accounting on bash bases
Online Einnahmen-Ausgaben-Rechnung
http://www.ea-geier.at
------------------------------------------------
m2m server software gmbh
http://www.m2m.at

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] php via cmdline including unwanted headers
Old
  (#3)
Guest
Guest
 
Posts: n/a
Default Re: [PHP] php via cmdline including unwanted headers - 06-02-2007, 07:55 PM

2007. 05. 30, szerda keltezéssel 02.11-kor Sebe ezt ÃÂ*rta:
> I run some scripts via php (cgi) which sends output to another file, but
> it's including unwanted cookie header, etc in the outfile.
>
> example:
>
> php /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>
> and at the top of news.xml i get:
>
> X-Powered-By: PHP/5.2.2
> Set-Cookie: .....
> Set-Cookie: .....
> Cache-Control: private
> Content-Type: text/html; charset=ISO-8859-1
>
> i turned off expose php which gets rid of the x-powered-by but what
> about the rest?
>


what if you just simply replace all echo-s with fwrite calls in the
script (of course with an fopen at the beginning and an fclose at the
end). you could p*** the filename as a parameter into $argv

greets
Zoltán Németh
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] php via cmdline including unwanted headers
Old
  (#4)
Sebe
Guest
 
Posts: n/a
Default Re: [PHP] php via cmdline including unwanted headers - 06-02-2007, 07:55 PM

Yeni Setiawan wrote:
>
>
> On 5/30/07, *Sebe* <EMAIL REMOVED <private.php?do=newpm&u=>>
> wrote:
>
> I run some scripts via php (cgi) which sends output to another
> file, but
> it's including unwanted cookie header, etc in the outfile.
>
> example:
>
> php /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>
> and at the top of news.xml i get:
>
> X-Powered-By: PHP/5.2.2
> Set-Cookie: .....
> Set-Cookie: .....
> Cache-Control: private
> Content-Type: text/html; charset=ISO-8859-1
>
> i turned off expose php which gets rid of the x-powered-by but what
> about the rest?
>
>
>
>
> try to use quiet mode by using -q option as follow:
>
> php -q /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>

i tried using -q
still shows the headers.. this problem started when i switched to php cgi.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] php via cmdline including unwanted headers
Old
  (#5)
Stut
Guest
 
Posts: n/a
Default Re: [PHP] php via cmdline including unwanted headers - 06-02-2007, 07:56 PM

Sebe wrote:
> Yeni Setiawan wrote:
>>
>>
>> On 5/30/07, *Sebe* <EMAIL REMOVED <private.php?do=newpm&u=>>
>> wrote:
>>
>> I run some scripts via php (cgi) which sends output to another
>> file, but
>> it's including unwanted cookie header, etc in the outfile.
>>
>> example:
>>
>> php /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>>
>> and at the top of news.xml i get:
>>
>> X-Powered-By: PHP/5.2.2
>> Set-Cookie: .....
>> Set-Cookie: .....
>> Cache-Control: private
>> Content-Type: text/html; charset=ISO-8859-1
>>
>> i turned off expose php which gets rid of the x-powered-by but what
>> about the rest?
>>
>>
>>
>>
>> try to use quiet mode by using -q option as follow:
>>
>> php -q /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>>

> i tried using -q
> still shows the headers.. this problem started when i switched to php cgi.


Well that's your mistake. The CGI binary is meant for use as a web page
generator. You need php-cli.

-Stut
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] php via cmdline including unwanted headers
Old
  (#6)
Sebe
Guest
 
Posts: n/a
Default Re: [PHP] php via cmdline including unwanted headers - 06-02-2007, 07:56 PM

Stut wrote:
> Sebe wrote:
>> Yeni Setiawan wrote:
>>>
>>>
>>> On 5/30/07, *Sebe* <EMAIL REMOVED <private.php?do=newpm&u=>>
>>> wrote:
>>>
>>> I run some scripts via php (cgi) which sends output to another
>>> file, but
>>> it's including unwanted cookie header, etc in the outfile.
>>>
>>> example:
>>>
>>> php /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>>>
>>> and at the top of news.xml i get:
>>>
>>> X-Powered-By: PHP/5.2.2
>>> Set-Cookie: .....
>>> Set-Cookie: .....
>>> Cache-Control: private
>>> Content-Type: text/html; charset=ISO-8859-1
>>>
>>> i turned off expose php which gets rid of the x-powered-by but what
>>> about the rest?
>>>
>>>
>>>
>>>
>>> try to use quiet mode by using -q option as follow:
>>>
>>> php -q /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>>>

>> i tried using -q
>> still shows the headers.. this problem started when i switched to php
>> cgi.

>
> Well that's your mistake. The CGI binary is meant for use as a web
> page generator. You need php-cli.
>
> -Stut


turning cgi.check_shebang_line in php.ini solved the problem without
using php cli
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] php via cmdline including unwanted headers
Old
  (#7)
Robert Cummings
Guest
 
Posts: n/a
Default Re: [PHP] php via cmdline including unwanted headers - 06-02-2007, 07:56 PM

On Wed, 2007-05-30 at 09:38 +0100, Stut wrote:
> Sebe wrote:
> >
> > i tried using -q
> > still shows the headers.. this problem started when i switched to php cgi.

>
> Well that's your mistake. The CGI binary is meant for use as a web page
> generator. You need php-cli.


While php-cli is an improvement over php-cgi for shell scripts it is not
a necessity unless you want better handling of stdin and the other
streams. That has been my experience, so much so that I haven't bothered
updating any old scripts that still make use of the php-cgi binary.
They've worked all the way from php 4.1.0 all the way through 5.2.0 (I
haven't bothered with 5.2.1 or 5.2.2 yet I do always run them with
the -qC flags though.

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] php via cmdline including unwanted headers
Old
  (#8)
Richard Lynch
Guest
 
Posts: n/a
Default Re: [PHP] php via cmdline including unwanted headers - 06-02-2007, 07:56 PM

php -q

On Wed, May 30, 2007 1:11 am, Sebe wrote:
> I run some scripts via php (cgi) which sends output to another file,
> but
> it's including unwanted cookie header, etc in the outfile.
>
> example:
>
> php /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>
> and at the top of news.xml i get:
>
> X-Powered-By: PHP/5.2.2
> Set-Cookie: .....
> Set-Cookie: .....
> Cache-Control: private
> Content-Type: text/html; charset=ISO-8859-1
>
> i turned off expose php which gets rid of the x-powered-by but what
> about the rest?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] php via cmdline including unwanted headers
Old
  (#9)
Richard Lynch
Guest
 
Posts: n/a
Default Re: [PHP] php via cmdline including unwanted headers - 06-02-2007, 07:56 PM



On Wed, May 30, 2007 2:47 am, Sebe wrote:
> Yeni Setiawan wrote:
>>
>>
>> On 5/30/07, *Sebe* <EMAIL REMOVED <private.php?do=newpm&u=>>
>> wrote:
>>
>> I run some scripts via php (cgi) which sends output to another
>> file, but
>> it's including unwanted cookie header, etc in the outfile.
>>
>> example:
>>
>> php /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>>
>> and at the top of news.xml i get:
>>
>> X-Powered-By: PHP/5.2.2
>> Set-Cookie: .....
>> Set-Cookie: .....
>> Cache-Control: private
>> Content-Type: text/html; charset=ISO-8859-1
>>
>> i turned off expose php which gets rid of the x-powered-by but
>> what
>> about the rest?
>>
>>
>>
>>
>> try to use quiet mode by using -q option as follow:
>>
>> php -q /home/dev/script.php > /home/production/feeds/news.xml 2>&1
>>

> i tried using -q
> still shows the headers.. this problem started when i switched to php
> cgi.


I guess that's why we have both CLI and CGI...

Go back to CLI, not CGI.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top