System scripting with PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maciej Zalewski

    System scripting with PHP

    Hello,

    I'd like to use PHP as simple, standalone system-scripting engine rather
    than HTML generating engine on Web Server.

    Executing simple file: HelloWorld.php
    =============== =========
    <?
    echo "Hello world!\r\n";
    ?>
    =============== =========

    I get raw output that looks like this:
    =============== =========
    X-Powered-By: PHP/4.1.2
    Content-type: text/html; charset=iso-8859-2

    Hello world!

    =============== =========

    How can I get rid of those X-Powered-By: and Content-type: headers from the
    script's output?

    --
    Maciej "Sasha" Zalewski

    GG# 1850769
    mail: josif[WYTNIJTO]@klub.chip.pl
    z mojego maila usuñ ca³y nawias kwadratowy

  • Jamie Davison

    #2
    Re: System scripting with PHP

    Suppress header output with the -q option

    Try php -q HelloWorld.php or /path/to/your/script/php -q HelloWorld.php

    On 9/24/04 3:45 PM, in article 01c4a26f$31f006 a0$bdc088c3@ssf .swiat_II,
    "Maciej Zalewski" <josif[WYTNIJTO]@klub.chip.pl> wrote:
    [color=blue]
    > Hello,
    >
    > I'd like to use PHP as simple, standalone system-scripting engine rather
    > than HTML generating engine on Web Server.
    >
    > Executing simple file: HelloWorld.php
    > =============== =========
    > <?
    > echo "Hello world!\r\n";
    > ?>
    > =============== =========
    >
    > I get raw output that looks like this:
    > =============== =========
    > X-Powered-By: PHP/4.1.2
    > Content-type: text/html; charset=iso-8859-2
    >
    > Hello world!
    >
    > =============== =========
    >
    > How can I get rid of those X-Powered-By: and Content-type: headers from the
    > script's output?[/color]

    Comment

    • Jamie Davison

      #3
      Re: System scripting with PHP

      Optionally, you could add it to your script . . .
      check the path to PHP Could be /usr/local/bin/php

      ---- Cut -----

      #!/usr/local/bin/php -q
      <?
      echo "Hello world!\r\n";
      ?>

      ---- End Cut -----

      Then execute: ./HelloWorld.php


      On 9/24/04 3:51 PM, in article BD79F2F3.AE9C%j davison_usa@yah oo.com, "Jamie
      Davison" <jdavison_usa@y ahoo.com> wrote:
      [color=blue]
      > Suppress header output with the -q option
      >
      > Try php -q HelloWorld.php or /path/to/your/script/php -q HelloWorld.php
      >
      > On 9/24/04 3:45 PM, in article 01c4a26f$31f006 a0$bdc088c3@ssf .swiat_II,
      > "Maciej Zalewski" <josif[WYTNIJTO]@klub.chip.pl> wrote:
      >[color=green]
      >> Hello,
      >>
      >> I'd like to use PHP as simple, standalone system-scripting engine rather
      >> than HTML generating engine on Web Server.
      >>
      >> Executing simple file: HelloWorld.php
      >> =============== =========
      >> <?
      >> echo "Hello world!\r\n";
      >> ?>
      >> =============== =========
      >>
      >> I get raw output that looks like this:
      >> =============== =========
      >> X-Powered-By: PHP/4.1.2
      >> Content-type: text/html; charset=iso-8859-2
      >>
      >> Hello world!
      >>
      >> =============== =========
      >>
      >> How can I get rid of those X-Powered-By: and Content-type: headers from the
      >> script's output?[/color]
      >[/color]

      Comment

      • Maciej Zalewski

        #4
        Re: System scripting with PHP


        Jamie Davison <jdavison_usa@y ahoo.com> napisa³(a) w artykule
        <BD79F2F3.AE9C% jdavison_usa@ya hoo.com>...[color=blue]
        > Suppress header output with the -q option
        >
        > Try php -q HelloWorld.php or /path/to/your/script/php -q HelloWorld.php[/color]

        It works! :)
        Thanks a lot.

        --
        Maciej "Sasha" Zalewski

        GG# 1850769
        mail: josif[WYTNIJTO]@klub.chip.pl
        z mojego maila usuñ ca³y nawias kwadratowy

        Comment

        • Simon Stienen

          #5
          Re: System scripting with PHP

          Jamie Davison <jdavison_usa@y ahoo.com> wrote:[color=blue]
          > Suppress header output with the -q option
          >
          > Try php -q HelloWorld.php or /path/to/your/script/php -q HelloWorld.php[/color]

          As written in the php cli online help (php -h), you should use
          php -f <file> rather than php -q <file> for command line scripts.
          Don't ask me, what the exact difference is, but I'm pretty sure, they
          wouldn't offer two different options to archive exactly the same goal.
          --
          Simon Stienen <http://dangerouscat.ne t> <http://slashlife.de>
          »What you do in this world is a matter of no consequence,
          The question is, what can you make people believe that you have done.«
          -- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle

          Comment

          • Jamie Davison

            #6
            Re: System scripting with PHP



            The php -f option will parse the input file. Simple server side would just
            need the -q option to suppress headers . . .

            See http://us2.php.net/features.commandline

            -Jamie



            On 9/24/04 5:13 PM, in article a00t0z9z0h3r.dl g@news.dangerou scat.net,
            "Simon Stienen" <simon.stienen@ news.slashlife. de> wrote:
            [color=blue]
            > Jamie Davison <jdavison_usa@y ahoo.com> wrote:[color=green]
            >> Suppress header output with the -q option
            >>
            >> Try php -q HelloWorld.php or /path/to/your/script/php -q HelloWorld.php[/color]
            >
            > As written in the php cli online help (php -h), you should use
            > php -f <file> rather than php -q <file> for command line scripts.
            > Don't ask me, what the exact difference is, but I'm pretty sure, they
            > wouldn't offer two different options to archive exactly the same goal.[/color]

            Comment

            Working...