shell_exec not working on Win2K3

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

    shell_exec not working on Win2K3

    Hi all,

    We have PHP 4 installed on Windows 2003 with Apache 2, and the
    shell_exec has mysteriously stopped working - it hangs the page rather
    then returning anything.

    To check it out, I tried shell_exec("dir ") which works fine on the
    development machine, but not on the live server.

    I'm guessing the network guys have done something to the security of
    the live server that would cause this - but it's very strange; why
    would Apache (running under the default system account) not allow PHP
    to run shell_exec statements?

    I have checked PHP and it's not in safe mode.

    I'm a bit stuck - any ideas would be appreciated...

  • d

    #2
    Re: shell_exec not working on Win2K3

    "jonathan.becke tt" <jonathan.becke tt@gmail.com> wrote in message
    news:1138970152 .834117.49630@o 13g2000cwo.goog legroups.com...[color=blue]
    > Hi all,
    >
    > We have PHP 4 installed on Windows 2003 with Apache 2, and the
    > shell_exec has mysteriously stopped working - it hangs the page rather
    > then returning anything.
    >
    > To check it out, I tried shell_exec("dir ") which works fine on the
    > development machine, but not on the live server.
    >
    > I'm guessing the network guys have done something to the security of
    > the live server that would cause this - but it's very strange; why
    > would Apache (running under the default system account) not allow PHP
    > to run shell_exec statements?
    >
    > I have checked PHP and it's not in safe mode.
    >
    > I'm a bit stuck - any ideas would be appreciated...[/color]

    Have you checked the permissions of the cmd.exe file in windows\system3 2?
    It has to be executable by the user the web server is running as... Usually
    that will return an error, though, so it might not be the cause of your
    problem... :)

    dave


    Comment

    • jonathan.beckett

      #3
      Re: shell_exec not working on Win2K3

      Nope - I just simulated that on the test server, and it doesn't hang
      the pages... it just returns nothing.

      The behaviour we are getting on the live server is that any page using
      shell_exec hangs the page - the browser just sits with the sand timer
      indefinitely...

      I'm still waiting for somebody to grab the apache logs for me -
      hopefully they will explain what is going on.

      If anybody else has any ideas I'd love to know.

      Comment

      • Erwin Moller

        #4
        Re: shell_exec not working on Win2K3

        jonathan.becket t wrote:
        [color=blue]
        > Hi all,
        >
        > We have PHP 4 installed on Windows 2003 with Apache 2, and the
        > shell_exec has mysteriously stopped working - it hangs the page rather
        > then returning anything.
        >
        > To check it out, I tried shell_exec("dir ") which works fine on the
        > development machine, but not on the live server.
        >
        > I'm guessing the network guys have done something to the security of
        > the live server that would cause this - but it's very strange; why
        > would Apache (running under the default system account) not allow PHP
        > to run shell_exec statements?
        >
        > I have checked PHP and it's not in safe mode.
        >
        > I'm a bit stuck - any ideas would be appreciated...[/color]

        Hi,

        Did you read the usercontributio ns on php.net?
        Maybe they contain a few hints.
        They can be found here:



        For example: Somebody complained that the systemcall didn't return. Turned
        out to be memorylimit for PHP wasn't enough for the command to complete
        succesfully.

        Read them, maybe you find something that is usefull.

        If that doesn't help: Please provide us with more information, like what you
        are calling, etc. etc.

        Regards,
        Erwin Moller

        Comment

        • jonathan.beckett

          #5
          Re: shell_exec not working on Win2K3

          Yep - I've already read the PHP website (it was the first place I
          looked after we found out shell_exec was misbehaving).

          Some background would probably help - the script call worked before the
          server was locked down and put in the DMZ for public access.

          Following that, the script call didn't work any more. I have stuck a
          test script on the server just calling shell_exec("dir "); and it's
          hanging... on my test box if I remove permissions on cmd.exe, it just
          returns an empty string (i.e. what you would expect).

          I'm still waiting for the apache logs - hopefully they will provide
          some more meaningful information...

          Comment

          • Erwin Moller

            #6
            Re: shell_exec not working on Win2K3

            jonathan.becket t wrote:
            [color=blue]
            > Yep - I've already read the PHP website (it was the first place I
            > looked after we found out shell_exec was misbehaving).[/color]

            Ok, good. :-)
            [color=blue]
            >
            > Some background would probably help - the script call worked before the
            > server was locked down and put in the DMZ for public access.[/color]

            Hmm, maybe your call to the program needs some network-access that is now
            blocked because of new location (DMZ)?

            [color=blue]
            >
            > Following that, the script call didn't work any more. I have stuck a
            > test script on the server just calling shell_exec("dir "); and it's
            > hanging... on my test box if I remove permissions on cmd.exe, it just
            > returns an empty string (i.e. what you would expect).[/color]

            Aha, so it has nothing to do with DMZ-blocked networkaccess.
            If even 'dir' doesn't return...

            [color=blue]
            >
            > I'm still waiting for the apache logs - hopefully they will provide
            > some more meaningful information...[/color]

            Did you turn on errorreporting to ALL?
            Or doesn't that help because the script just times-out?

            Well, I am out of ideas as you can see. :-/

            Let us know what you find (with apachelogs maybe), and please: if you fix
            it: tell us all how on php.net. :-)

            Good luck,
            Erwin Moller

            Comment

            • Good Man

              #7
              Re: shell_exec not working on Win2K3

              "jonathan.becke tt" <jonathan.becke tt@gmail.com> wrote in
              news:1138970152 .834117.49630@o 13g2000cwo.goog legroups.com:
              [color=blue]
              > Hi all,
              >
              > We have PHP 4 installed on Windows 2003 with Apache 2, and the
              > shell_exec has mysteriously stopped working - it hangs the page rather
              > then returning anything.[/color]

              hi

              try using backticks:

              ln 1:$myCommand = "some code that will do things on the server";
              ln 2:`$myCommand`;

              instead of
              ln 2:shell_exec($m yCommand);


              the backtick thing has worked for me in all instances where shell_exec,
              exec have not.



              Comment

              Working...