exec returns -1

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

    #1

    exec returns -1

    I've narrowed the code to a problem with php/iplanet on linux. When I
    run the following code from the command line "$status" comes back as
    "0" as it should. However when I hit it with a browser, status is "-1".
    Im guessing it has something to do with the way iplanet is invoking
    php, or how php was compiled. Oddly enough I have the same setup
    running on windows with php 4&5 and it always returns "0". Lucky for me
    I suppose... Anyone know how to fix this? Is it as simple as
    recompiling with additional options?

    You can view my results here: http://www.69camaro.us/test/go.php

    OS: fedora C4
    PHP: 4.4.2
    Iplanet: 6.1 sp5

    <?php

    $command='echo "hello world"';
    $results = array();
    $Output = exec($command, $results, $status);

    print " Output: $Output<br><br> ";
    print "command: $command <br>";
    print "results: $results <br>";
    print " status: $status <br>";

    ?>

  • d

    #2
    Re: exec returns -1

    "inetquesti on" <inetquestion@h otmail.com> wrote in message
    news:1145162738 .962086.291750@ v46g2000cwv.goo glegroups.com.. .[color=blue]
    > I've narrowed the code to a problem with php/iplanet on linux. When I
    > run the following code from the command line "$status" comes back as
    > "0" as it should. However when I hit it with a browser, status is "-1".
    > Im guessing it has something to do with the way iplanet is invoking
    > php, or how php was compiled. Oddly enough I have the same setup
    > running on windows with php 4&5 and it always returns "0". Lucky for me
    > I suppose... Anyone know how to fix this? Is it as simple as
    > recompiling with additional options?
    >
    > You can view my results here: http://www.69camaro.us/test/go.php
    >
    > OS: fedora C4
    > PHP: 4.4.2
    > Iplanet: 6.1 sp5
    >
    > <?php
    >
    > $command='echo "hello world"';
    > $results = array();
    > $Output = exec($command, $results, $status);
    >
    > print " Output: $Output<br><br> ";
    > print "command: $command <br>";
    > print "results: $results <br>";
    > print " status: $status <br>";
    >
    > ?>[/color]

    There is no reason to use eval. It's evil.

    "If eval is the answer, you're asking the wrong question"


    Comment

    • Jerry Stuckle

      #3
      Re: exec returns -1

      d wrote:[color=blue]
      > "inetquesti on" <inetquestion@h otmail.com> wrote in message
      > news:1145162738 .962086.291750@ v46g2000cwv.goo glegroups.com.. .
      >[color=green]
      >>I've narrowed the code to a problem with php/iplanet on linux. When I
      >>run the following code from the command line "$status" comes back as
      >>"0" as it should. However when I hit it with a browser, status is "-1".
      >>Im guessing it has something to do with the way iplanet is invoking
      >>php, or how php was compiled. Oddly enough I have the same setup
      >>running on windows with php 4&5 and it always returns "0". Lucky for me
      >>I suppose... Anyone know how to fix this? Is it as simple as
      >>recompiling with additional options?
      >>
      >>You can view my results here: http://www.69camaro.us/test/go.php
      >>
      >>OS: fedora C4
      >>PHP: 4.4.2
      >>Iplanet: 6.1 sp5
      >>
      >><?php
      >>
      >>$command='ech o "hello world"';
      >>$results = array();
      >>$Output = exec($command, $results, $status);
      >>
      >>print " Output: $Output<br><br> ";
      >>print "command: $command <br>";
      >>print "results: $results <br>";
      >>print " status: $status <br>";
      >>
      >>?>[/color]
      >
      >
      > There is no reason to use eval. It's evil.
      >
      > "If eval is the answer, you're asking the wrong question"
      >
      >[/color]

      I don't see anyone using eval here.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Jerry Stuckle

        #4
        Re: exec returns -1

        inetquestion wrote:[color=blue]
        > I've narrowed the code to a problem with php/iplanet on linux. When I
        > run the following code from the command line "$status" comes back as
        > "0" as it should. However when I hit it with a browser, status is "-1".
        > Im guessing it has something to do with the way iplanet is invoking
        > php, or how php was compiled. Oddly enough I have the same setup
        > running on windows with php 4&5 and it always returns "0". Lucky for me
        > I suppose... Anyone know how to fix this? Is it as simple as
        > recompiling with additional options?
        >
        > You can view my results here: http://www.69camaro.us/test/go.php
        >
        > OS: fedora C4
        > PHP: 4.4.2
        > Iplanet: 6.1 sp5
        >
        > <?php
        >
        > $command='echo "hello world"';
        > $results = array();
        > $Output = exec($command, $results, $status);
        >
        > print " Output: $Output<br><br> ";
        > print "command: $command <br>";
        > print "results: $results <br>";
        > print " status: $status <br>";
        >
        > ?>
        >[/color]

        I'd suggest it's probably a permissions problem. Anything in your error logs?

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • inetquestion

          #5
          Re: exec returns -1

          The echo actually suceeds, so there are no errors associated with
          running this command or loading the page.

          Comment

          • inetquestion

            #6
            Re: exec returns -1

            ok, not sure what you mean about eval since its nowhere in the code I
            posted. However this example is similar to a function that is failing
            when I try to enable Imagemagick in gallery 2.2 & 2.1. Since the
            gallery folks do not support Iplanet I'm more or less left to my own
            devices to breakdown the code and find the core problem, which is what
            I've done here. Unfortunately I've broken it down as far as I can for
            now...hence the post here.

            Comment

            • d

              #7
              Re: exec returns -1

              "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
              news:MMadneuiU8 Wt_d_ZnZ2dnUVZ_ s-dnZ2d@comcast.c om...[color=blue]
              >d wrote:[color=green]
              >> "inetquesti on" <inetquestion@h otmail.com> wrote in message
              >> news:1145162738 .962086.291750@ v46g2000cwv.goo glegroups.com.. .
              >>[color=darkred]
              >>>I've narrowed the code to a problem with php/iplanet on linux. When I
              >>>run the following code from the command line "$status" comes back as
              >>>"0" as it should. However when I hit it with a browser, status is "-1".
              >>>Im guessing it has something to do with the way iplanet is invoking
              >>>php, or how php was compiled. Oddly enough I have the same setup
              >>>running on windows with php 4&5 and it always returns "0". Lucky for me
              >>>I suppose... Anyone know how to fix this? Is it as simple as
              >>>recompilin g with additional options?
              >>>
              >>>You can view my results here: http://www.69camaro.us/test/go.php
              >>>
              >>>OS: fedora C4
              >>>PHP: 4.4.2
              >>>Iplanet: 6.1 sp5
              >>>
              >>><?php
              >>>
              >>>$command='ec ho "hello world"';
              >>>$results = array();
              >>>$Output = exec($command, $results, $status);
              >>>
              >>>print " Output: $Output<br><br> ";
              >>>print "command: $command <br>";
              >>>print "results: $results <br>";
              >>>print " status: $status <br>";
              >>>
              >>>?>[/color]
              >>
              >>
              >> There is no reason to use eval. It's evil.
              >>
              >> "If eval is the answer, you're asking the wrong question"[/color]
              >
              > I don't see anyone using eval here.[/color]

              that's what I get when I post after having a few beers :)
              [color=blue]
              > --
              > =============== ===
              > Remove the "x" from my email address
              > Jerry Stuckle
              > JDS Computer Training Corp.
              > jstucklex@attgl obal.net
              > =============== ===[/color]


              Comment

              • Gordon Burditt

                #8
                Re: exec returns -1

                >I've narrowed the code to a problem with php/iplanet on linux. When I[color=blue]
                >run the following code from the command line "$status" comes back as
                >"0" as it should. However when I hit it with a browser, status is "-1".
                >Im guessing it has something to do with the way iplanet is invoking
                >php, or how php was compiled. Oddly enough I have the same setup
                >running on windows with php 4&5 and it always returns "0". Lucky for me
                >I suppose... Anyone know how to fix this? Is it as simple as
                >recompiling with additional options?[/color]

                Where is the executable for the "echo" command? (answer for both
                setups). Is the directory the executable for the "echo" command
                is in listed in $PATH (answer for both setups)? Is safe mode on,
                and if so, is the executable for "echo" present in a directory
                listed in safe_mode_exec_ dir (answer for both setups)?

                Note that I don't see anything in the description of exec() that
                says you can use shell builtin commands (just as you can't on the
                C exec() function).

                Gordon L. Burditt

                Comment

                • inetquestion

                  #9
                  Re: exec returns -1

                  Checked and the 'echo' binary is in /bin/echo. The PATH for a user
                  ssh'd in and that of a script being executed by the browser both
                  include "/bin", so there is no issue from that perspective. This can
                  also be confirmed that it is working from the output below. Since it
                  sucessfully produces the string "hello world". The echo command is
                  working, however the result code which exec is setting is always set to
                  -1 when the script is invoked by the webserver. This is true even if
                  the command you are trying to run is invalid or does not exist. If I
                  run the same script with an invalid command from the command line, the
                  exec function in this scenario gives a status of 127.



                  This is the output from hitting this script on a webserver with a
                  browser:
                  ############### ########
                  Output: hello world

                  command: echo "hello world"
                  results: Array
                  status: -1
                  ############### ########

                  This is the output from hitting this script through an ssh session and
                  running "php go.php"
                  ############### ########
                  Output: hello world<br><br>co mmand: echo "hello world" <br>results:
                  Array <br> status: 0 <br>
                  ############### ########

                  Comment

                  • inetquestion

                    #10
                    Re: exec returns -1

                    Does php need to be compiled with a special option for use on
                    iplanet/sunone webservers on linux for the exec function to work
                    properly?

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: exec returns -1

                      inetquestion wrote:[color=blue]
                      > Does php need to be compiled with a special option for use on
                      > iplanet/sunone webservers on linux for the exec function to work
                      > properly?
                      >[/color]

                      They may have safe_mode on or exec() disabled. What does phpinfo() say?

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • inetquestion

                        #12
                        Re: exec returns -1

                        I think they are off, but you can see the output here:



                        Comment

                        • Jerry Stuckle

                          #13
                          Re: exec returns -1

                          inetquestion wrote:[color=blue]
                          > I think they are off, but you can see the output here:
                          >
                          > http://www.69camaro.us/test
                          >[/color]

                          Ah, I missed the fact you're using Sun.

                          It has some security features in it, also. I've never used it, but I've heard
                          of people who have problems with it.

                          Maybe someone familiar with it can hop in here.

                          --
                          =============== ===
                          Remove the "x" from my email address
                          Jerry Stuckle
                          JDS Computer Training Corp.
                          jstucklex@attgl obal.net
                          =============== ===

                          Comment

                          • inetquestion

                            #14
                            Re: exec returns -1

                            Any other iplanet/php peeps out there?

                            Comment

                            Working...