unexpected cli behavior

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

    unexpected cli behavior

    i have the following two php scripts:

    test.php:
    <?
    print system('./test-cli.php');
    ?>

    test-cli.php:
    #!/usr/local/bin/php -q
    <?
    print "hello, world!";
    ?>

    when i run test.php from a webserver (test-cli.php is in the same
    directory as test.php) i get the following output:

    Usage: php [options] [-f] [args...] php [options] -r [args...] php
    [options] [-- args...] -a Run interactively -c | 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 Parse . -h This help -i PHP information -l Syntax
    check only (lint) -m Show compiled in modules -r Run PHP without using
    script tags -s Display colour syntax highlighted source. -v Version
    number -w Display source with stripped comments and whitespace. -z
    Load Zend extension . args... Arguments passed to script. Use -- args
    when first argument starts with - or script is read from stdin starts
    with - or script is read from stdin

    so... what does this mean, and how do i fix it? any help would be
    appreciated - thanks! :)
  • Erich Musick

    #2
    Re: unexpected cli behavior

    What if, in test.php you tried:

    <?
    print system('/usr/local/bin/php -q ./test-cli.php');
    ?>



    yawnmoth wrote:[color=blue]
    > i have the following two php scripts:
    >
    > test.php:
    > <?
    > print system('./test-cli.php');
    > ?>
    >
    > test-cli.php:
    > #!/usr/local/bin/php -q
    > <?
    > print "hello, world!";
    > ?>
    >
    > when i run test.php from a webserver (test-cli.php is in the same
    > directory as test.php) i get the following output:
    >
    > Usage: php [options] [-f] [args...] php [options] -r [args...] php
    > [options] [-- args...] -a Run interactively -c | 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 Parse . -h This help -i PHP information -l Syntax
    > check only (lint) -m Show compiled in modules -r Run PHP without using
    > script tags -s Display colour syntax highlighted source. -v Version
    > number -w Display source with stripped comments and whitespace. -z
    > Load Zend extension . args... Arguments passed to script. Use -- args
    > when first argument starts with - or script is read from stdin starts
    > with - or script is read from stdin
    >
    > so... what does this mean, and how do i fix it? any help would be
    > appreciated - thanks! :)[/color]

    --
    In Christ,

    Erich Musick


    In the same way, let your light shine before others, so that they may
    see your good works and give glory to your Father who is in heaven. --
    Matthew 5:16 NKJV

    Comment

    • yawnmoth

      #3
      Re: unexpected cli behavior

      Erich Musick <erich.musick@s bcglobal.net> wrote in message news:<yEzmd.96$ rp2.68@newssvr3 1.news.prodigy. com>...[color=blue]
      > What if, in test.php you tried:
      >
      > <?
      > print system('/usr/local/bin/php -q ./test-cli.php');
      > ?>[/color]

      would that call the cli version, though? 'cause if it didn't,
      wouldn't i be risking a so-called fork bomb, whereby a bunch of
      processes are created, but none are closed?

      Comment

      • 2metre

        #4
        Re: unexpected cli behavior

        yawnmoth wrote:[color=blue]
        > Erich Musick <erich.musick@s bcglobal.net> wrote in message news:<yEzmd.96$ rp2.68@newssvr3 1.news.prodigy. com>...
        >[color=green]
        >>What if, in test.php you tried:
        >>
        >><?
        >> print system('/usr/local/bin/php -q ./test-cli.php');
        >>?>[/color]
        >
        >
        > would that call the cli version, though? 'cause if it didn't,
        > wouldn't i be risking a so-called fork bomb, whereby a bunch of
        > processes are created, but none are closed?[/color]
        if the version of PHP at /usr/local/bin/php is the cli version, then yes
        you are calling the cli version.

        if the version of PHP at /usr/local/bin/php is NOT the cli version, then
        no, you are NOT calling the cli version!

        Comment

        • yawnmoth

          #5
          Re: unexpected cli behavior

          2metre <2metre@xxxhers ham.net> wrote in message news:<cnhnp6$lt 2$1@titan.btint ernet.com>...[color=blue]
          > yawnmoth wrote:[color=green]
          > > Erich Musick <erich.musick@s bcglobal.net> wrote in message news:<yEzmd.96$ rp2.68@newssvr3 1.news.prodigy. com>...
          > >[color=darkred]
          > >> <snip>[/color][/color]
          > if the version of PHP at /usr/local/bin/php is the cli version, then yes
          > you are calling the cli version.
          >
          > if the version of PHP at /usr/local/bin/php is NOT the cli version, then
          > no, you are NOT calling the cli version![/color]

          how would i know if it's the cli version or not? i'm running this on
          a website that's hosted by some hosting company, so it's not as if i
          installed php myself...

          Comment

          Working...