command-line PHP problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • comp.lang.php

    command-line PHP problem

    I am trying to simply pipe in 2 very small commands and not have to
    create a PHP script to do this:

    php -r >>END; require_once('/var/www/html/tools/functions.inc.p hp');
    echo
    xml_to_tcl_list (file_get_conte nts('/var/www/html/tools/app/xml/data.xml'));
    END
    However, I do not have the "-r" option in PHP 4.3.9, and I would think
    that I would, but why not? Here is all I have to work with:

    php -h
    Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
    php <file[args...]
    -a Run interactively
    -C Do not chdir to the script's directory
    -c <path>|<fileLoo k for php.ini file in this directory
    -n No php.ini file will be used
    -d foo[=bar] Define INI entry foo with value 'bar'
    -e Generate extended information for debugger/profiler
    -f <file Parse <file>. Implies `-q'
    -h This help
    -i PHP information
    -l Syntax check only (lint)
    -m Show compiled in modules
    -q Quiet-mode. Suppress HTTP Header output.
    -s Display colour syntax highlighted source.
    -v Version number
    -w Display source with stripped comments and
    whitespace.
    -z <file Load Zend extension <file>.
    [phillip@www2 ~]$ php "phpinfo()"
    Status: 404
    Content-type: text/html
    X-Powered-By: PHP/4.3.9

    No input file specified.
    What should I do?

    Thanx
    Phil

  • Dave Kelly

    #2
    Re: command-line PHP problem

    comp.lang.php wrote:
    I am trying to simply pipe in 2 very small commands and not have to
    create a PHP script to do this:
    >
    php -r >>END; require_once('/var/www/html/tools/functions.inc.p hp');
    echo
    xml_to_tcl_list (file_get_conte nts('/var/www/html/tools/app/xml/data.xml'));
    END
    >
    However, I do not have the "-r" option in PHP 4.3.9, and I would think
    that I would, but why not? Here is all I have to work with:
    >
    php -h
    Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
    php <file[args...]
    -a Run interactively
    -C Do not chdir to the script's directory
    -c <path>|<fileLoo k for php.ini file in this directory
    -n No php.ini file will be used
    -d foo[=bar] Define INI entry foo with value 'bar'
    -e Generate extended information for debugger/profiler
    -f <file Parse <file>. Implies `-q'
    -h This help
    -i PHP information
    -l Syntax check only (lint)
    -m Show compiled in modules
    -q Quiet-mode. Suppress HTTP Header output.
    -s Display colour syntax highlighted source.
    -v Version number
    -w Display source with stripped comments and
    whitespace.
    -z <file Load Zend extension <file>.
    [phillip@www2 ~]$ php "phpinfo()"
    Status: 404
    Content-type: text/html
    X-Powered-By: PHP/4.3.9
    >
    No input file specified.
    >
    What should I do?
    >
    Thanx
    Phil
    >
    Thats interesting because I do.

    SilverNail:~# php -hv
    Usage: php [options] [-f] <file [args...]
    php [options] -r <code [args...]
    php [options] [-- args...]
    -a Run interactively
    -c <path|<file Look for php.ini file in this directory
    -n No php.ini file will be used
    -d foo[=bar] Define INI entry foo with value 'bar'
    -e Generate extended information for debugger/profiler
    -f <file Parse <file.
    -h This help
    -i PHP information
    -l Syntax check only (lint)
    -m Show compiled in modules
    -r <code Run PHP <code without using script tags <?..?
    -s Display colour syntax highlighted source.
    -v Version number
    -w Display source with stripped comments and whitespace.
    -z <file Load Zend extension <file.

    args... Arguments passed to script. Use -- args when first
    argument
    starts with - or script is read from stdin

    SilverNail:~# php -v
    PHP 4.3.9-2 (cli) (built: Dec 2 2004 05:45:27)
    Copyright (c) 1997-2004 The PHP Group
    Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
    SilverNail:~#






    Comment

    • comp.lang.php

      #3
      Re: command-line PHP problem


      Dave Kelly wrote:
      comp.lang.php wrote:
      I am trying to simply pipe in 2 very small commands and not have to
      create a PHP script to do this:

      php -r >>END; require_once('/var/www/html/tools/functions.inc.p hp');
      echo
      xml_to_tcl_list (file_get_conte nts('/var/www/html/tools/app/xml/data.xml'));
      END
      However, I do not have the "-r" option in PHP 4.3.9, and I would think
      that I would, but why not? Here is all I have to work with:

      php -h
      Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
      php <file[args...]
      -a Run interactively
      -C Do not chdir to the script's directory
      -c <path>|<fileLoo k for php.ini file in this directory
      -n No php.ini file will be used
      -d foo[=bar] Define INI entry foo with value 'bar'
      -e Generate extended information for debugger/profiler
      -f <file Parse <file>. Implies `-q'
      -h This help
      -i PHP information
      -l Syntax check only (lint)
      -m Show compiled in modules
      -q Quiet-mode. Suppress HTTP Header output.
      -s Display colour syntax highlighted source.
      -v Version number
      -w Display source with stripped comments and
      whitespace.
      -z <file Load Zend extension <file>.
      [phillip@www2 ~]$ php "phpinfo()"
      Status: 404
      Content-type: text/html
      X-Powered-By: PHP/4.3.9

      No input file specified.
      What should I do?

      Thanx
      Phil
      >
      Thats interesting because I do.
      >
      Any ideas as to why?

      Comment

      • petersprc

        #4
        Re: command-line PHP problem

        You might be running a php compiled in CGI SAPI mode. Is there another
        php on your system that you might be able to use? For example,
        /usr/bin/php might be the CGI version, and /usr/local/bin/php might be
        the CLI one.

        In any case, you can still use your CGI mode php if you write the
        commands into PHP's stdin:

        echo '<? phpinfo() ?>' | php

        comp.lang.php wrote:
        I am trying to simply pipe in 2 very small commands and not have to
        create a PHP script to do this:
        >
        php -r >>END; require_once('/var/www/html/tools/functions.inc.p hp');
        echo
        xml_to_tcl_list (file_get_conte nts('/var/www/html/tools/app/xml/data.xml'));
        END
        >
        However, I do not have the "-r" option in PHP 4.3.9, and I would think
        that I would, but why not? Here is all I have to work with:
        >
        php -h
        Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
        php <file[args...]
        -a Run interactively
        -C Do not chdir to the script's directory
        -c <path>|<fileLoo k for php.ini file in this directory
        -n No php.ini file will be used
        -d foo[=bar] Define INI entry foo with value 'bar'
        -e Generate extended information for debugger/profiler
        -f <file Parse <file>. Implies `-q'
        -h This help
        -i PHP information
        -l Syntax check only (lint)
        -m Show compiled in modules
        -q Quiet-mode. Suppress HTTP Header output.
        -s Display colour syntax highlighted source.
        -v Version number
        -w Display source with stripped comments and
        whitespace.
        -z <file Load Zend extension <file>.
        [phillip@www2 ~]$ php "phpinfo()"
        Status: 404
        Content-type: text/html
        X-Powered-By: PHP/4.3.9
        >
        No input file specified.
        >
        What should I do?
        >
        Thanx
        Phil

        Comment

        • comp.lang.php

          #5
          Re: command-line PHP problem


          petersprc wrote:
          You might be running a php compiled in CGI SAPI mode. Is there another
          php on your system that you might be able to use? For example,
          /usr/bin/php might be the CGI version, and /usr/local/bin/php might be
          the CLI one.
          Sorry apparently there is only /usr/local/bin/php and that does not
          offer the -r option; how can I tell it is in CGI SAPI mode?
          >
          In any case, you can still use your CGI mode php if you write the
          commands into PHP's stdin:
          >
          echo '<? phpinfo() ?>' | php
          Thanx! That did the trick perfectly!!

          Phil
          >
          comp.lang.php wrote:
          I am trying to simply pipe in 2 very small commands and not have to
          create a PHP script to do this:

          php -r >>END; require_once('/var/www/html/tools/functions.inc.p hp');
          echo
          xml_to_tcl_list (file_get_conte nts('/var/www/html/tools/app/xml/data.xml'));
          END
          However, I do not have the "-r" option in PHP 4.3.9, and I would think
          that I would, but why not? Here is all I have to work with:

          php -h
          Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
          php <file[args...]
          -a Run interactively
          -C Do not chdir to the script's directory
          -c <path>|<fileLoo k for php.ini file in this directory
          -n No php.ini file will be used
          -d foo[=bar] Define INI entry foo with value 'bar'
          -e Generate extended information for debugger/profiler
          -f <file Parse <file>. Implies `-q'
          -h This help
          -i PHP information
          -l Syntax check only (lint)
          -m Show compiled in modules
          -q Quiet-mode. Suppress HTTP Header output.
          -s Display colour syntax highlighted source.
          -v Version number
          -w Display source with stripped comments and
          whitespace.
          -z <file Load Zend extension <file>.
          [phillip@www2 ~]$ php "phpinfo()"
          Status: 404
          Content-type: text/html
          X-Powered-By: PHP/4.3.9

          No input file specified.
          What should I do?

          Thanx
          Phil

          Comment

          Working...