find if exec is enabled

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xhunter
    New Member
    • May 2007
    • 42

    find if exec is enabled

    I am working on a script for my users, in which at a part of it i want to let them know if "exec" command is enabled and can be used in their server,
    is that possible?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    The documentation doesn't mention the possibility that the exec (or other similar functions) can be disabled.

    The only thing I can think of is to use the function_exists function to check if the exec function exists.

    Comment

    • xhunter
      New Member
      • May 2007
      • 42

      #3
      Originally posted by Atli
      Hi.

      The documentation doesn't mention the possibility that the exec (or other similar functions) can be disabled.

      The only thing I can think of is to use the function_exists function to check if the exec function exists.
      many hosts do disable it,
      i think it works like adding it to the php.ini :
      [PHP]disable_functio ns = exec[/PHP]

      I am not sure that "function_exist s" would really work, and since my host has it disabled and I don't have access to a host with exec enabled, I can't check it.

      I was wondering if a way is known to check for it.

      edit:
      disabled/enabled, i think it returns that the function exists, but when disabled, it doesn't work.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        You could always just try to use it and see if it works.

        Like, for example:
        [code=php]
        function checkExec() {
        # Check if the function exists
        if(!function_ex ists("exec")) {
        return false;
        }

        # Check if the function works
        exec("echo enabled", $output);
        if($output[0] == "enabled") {
        return true;
        } else {
        return false;
        }
        )
        [/code]

        Comment

        • xhunter
          New Member
          • May 2007
          • 42

          #5
          Originally posted by Atli
          You could always just try to use it and see if it works.

          Like, for example:
          [code=php]
          function checkExec() {
          # Check if the function exists
          if(!function_ex ists("exec")) {
          return false;
          }

          # Check if the function works
          exec("echo enabled", $output);
          if($output[0] == "enabled") {
          return true;
          } else {
          return false;
          }
          )
          [/code]
          thanks, I will use that, hope it works with no errors,
          i can't be sure of anything unless I could try it for every situtation

          Comment

          Working...