PHP exec

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

    PHP exec

    Hello All . . .

    I need some help about exec command.

    I have create an executable that return the System Drives. It is based
    on DOS and does not need any parameter.

    I have create my php script that executes the executable i've create
    and the source code is the following :

    ############### ############### ############
    php:

    exec("SystemDri ves", $out);

    for($i = 0; $i <= sizeof($out)-1; $i++)
    {
    echo $out[$i];
    execMediaID($ou t[$i]);
    echo "<br />";
    }


    ############### ############### ############

    The php script is in the followin directory :

    http://localhost/My Application/Applications/SystemDrives.ph p

    in the same directory is and the executable

    http://localhost/My Application/Application/SystemDrives.ex e


    The problem is that if i will call the SystemDrives.ph p from parent
    directory then i don't get any result.

    For example if i will execute the following script i don't have any
    result


    php:
    index.php
    <?php
    include_once("A pplications/SystemDrives.ph p");
    ?>


    that the index located in the following directory

    http://localhost/My Application/index.php



    What can i do to execute the directories.
    ------------------------------------------------------------------------------------------------------------------------------------------

    Thanks a lot . . .

  • shimmyshack

    #2
    Re: PHP exec

    On May 7, 7:41 am, CorfuVBProgramm er <merianosni...@ gmail.comwrote:
    Hello All . . .
    >
    I need some help about exec command.
    >
    I have create an executable that return the System Drives. It is based
    on DOS and does not need any parameter.
    >
    I have create my php script that executes the executable i've create
    and the source code is the following :
    >
    ############### ############### ############
    php:
    >
    exec("SystemDri ves", $out);
    >
    for($i = 0; $i <= sizeof($out)-1; $i++)
    {
    echo $out[$i];
    execMediaID($ou t[$i]);
    echo "<br />";
    >
    }
    >
    ############### ############### ############
    >
    The php script is in the followin directory :
    >

    >
    in the same directory is and the executable
    >

    >
    The problem is that if i will call the SystemDrives.ph p from parent
    directory then i don't get any result.
    >
    For example if i will execute the following script i don't have any
    result
    >
    php:
    index.php
    <?php
    include_once("A pplications/SystemDrives.ph p");
    ?>
    >
    that the index located in the following directory
    >

    >
    What can i do to execute the directories.
    ------------------------------------------------------------------------------------------------------------------------------------------
    >
    Thanks a lot . . .
    use absolute paths, or use chdir() before you attempt to call an
    executable, this is a path issue. the OS will only find the exe if you
    tell it where it lives, or if the exe is in the PATH.

    Comment

    • shimmyshack

      #3
      Re: PHP exec

      On May 7, 11:27 am, shimmyshack <matt.fa...@gma il.comwrote:
      On May 7, 7:41 am, CorfuVBProgramm er <merianosni...@ gmail.comwrote:
      >
      >
      >
      Hello All . . .
      >
      I need some help about exec command.
      >
      I have create an executable that return the System Drives. It is based
      on DOS and does not need any parameter.
      >
      I have create my php script that executes the executable i've create
      and the source code is the following :
      >
      ############### ############### ############
      php:
      >
      exec("SystemDri ves", $out);
      >
      for($i = 0; $i <= sizeof($out)-1; $i++)
      {
      echo $out[$i];
      execMediaID($ou t[$i]);
      echo "<br />";
      >
      }
      >
      ############### ############### ############
      >
      The php script is in the followin directory :
      >>
      in the same directory is and the executable
      >>
      The problem is that if i will call the SystemDrives.ph p from parent
      directory then i don't get any result.
      >
      For example if i will execute the following script i don't have any
      result
      >
      php:
      index.php
      <?php
      include_once("A pplications/SystemDrives.ph p");
      ?>
      >
      that the index located in the following directory
      >>
      What can i do to execute the directories.
      ------------------------------------------------------------------------------------------------------------------------------------------
      >
      Thanks a lot . . .
      >
      use absolute paths, or use chdir() before you attempt to call an
      executable, this is a path issue. the OS will only find the exe if you
      tell it where it lives, or if the exe is in the PATH.
      also it might be worth saying that on your OS, do you know which is
      executed first
      program.bat
      program.com
      program.exe
      so when you use the command
      exec('program', $out);
      what are you going to get in a directory where all three exist, or if
      none exist!! (so the OS searches the path)
      is there any harm in being exact?

      Comment

      • =?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?=

        #4
        Re: PHP exec

        CorfuVBProgramm er wrote:
        What can i do to execute the directories.
        Aaaaaahhh, you need to program in a unix system some day, and you'll be
        enlightened.

        Either refer to the parent directory (".."), or use the $PATH environment
        variable.

        --
        ----------------------------------
        Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

        Fortune: You will be attacked next Wednesday at 3:15 p.m. by six samurai
        sword wielding purple fish glued to Harley-Davidson motorcycles.

        Oh, and have a nice day!
        -- Bryce Nesbitt '84

        Comment

        • CorfuVBProgrammer

          #5
          Re: PHP exec

          The problem solved . . .

          I changes the working directory and now i can execute perfectly my
          executable . . . .


          Thanks a lot . . . . :D

          Kind Regards

          Merianos Nikos

          Comment

          Working...