pasing part of an URL to commandline php

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

    pasing part of an URL to commandline php

    Hi All

    I have an URL like this




    I would like to call now the command line php like this:

    php graphthis.php '?csv=/tmp/data.cvs&dir=/web/htdocs/stress&monitor= aaa'

    The question is can php translate this parameter string into the $_GET[]
    aray somehow, so I don't have to rewrite the script ?

    Thanks in advance
    Heinz


  • Nikolai Chuvakhin

    #2
    Re: pasing part of an URL to commandline php

    "Heinz" <lullundlall@ya hoo.com> wrote in message
    news:<2ms3dsFpm p92U1@uni-berlin.de>...[color=blue]
    >
    > I have an URL like this
    >
    > http://system/web/htdocs/graphthis.p...ss&monitor=aaa
    >
    > I would like to call now the command line php like this:
    >
    > php graphthis.php '?csv=/tmp/data.cvs&dir=/web/htdocs/stress&monitor= aaa'
    >
    > The question is can php translate this parameter string into the $_GET[]
    > aray somehow, so I don't have to rewrite the script ?[/color]

    Most likely, you will have to add a few things to your script.
    In the command-line mode, arguments are stored in the $argv
    variable (also accessible via $_SERVER['argv']).

    Note also that you can recognize the mode in which PHP is running
    by calling the php_sapi_name() function.

    Cheers,
    NC

    Comment

    Working...