Exec() function not doing as I want (OSX)

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

    #16
    Re: Exec() function not doing as I want (OSX)

    On Sep 23, 3:36 pm, Maarten <b...@blah.comw rote:
    Bill H wrote:
    On Sep 19, 3:35 pm, Maarten <b...@blah.comw rote:
    Howdy,
    >
    Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
    I have a little problem with one function within my cd-management script.
    >
    For extracting a bit of info from my cd's I have an executable which I
    execute with exec():
    >
         $discOutput = exec('./discid /dev/rdisk2');
    >
    The executable is in the same directory as the php script is in. When I
    run the same line from Terminal within that same directory it gives me
    the output I want, php doesn't give me any ouput at all.
    >
    Asking exec() for output on a basic function like 'ls' does return a
    value, so the function is active. I guess somehow I am not pointing to
    the discid executable correctly, but I don't see what is wrong.
    >
    Can someone tell me what I am doing wrong?
    >
    Thanks in advance, Maarten
    >
    I had a similar issue when runnning a script in linux under apache. It
    took awhile for me to figure out I had to "cd" to the directory I
    wanted to work in and use an absolute path to the exe that is being
    executed. You may want to try something like this:
    >
    $discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
    >
    Bill H
    >
    I changed the code to:
    >
         $discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
    $ooutpuut);
    >
    Also have I changed the permission of discid to 555. No change, however.
    The problem remains. Both returned variable/array are empty.
    >
    Maarten- Hide quoted text -
    >
    - Show quoted text -
    Also this should not apply to Mac OSX, but on Vista with Xampp, to get
    executables to run from the exec() in php, I had to chase down cmd.exe
    in the windows\system3 2 folder and set it to always run as
    administrator before any exe's were executable using exec(). Maybe
    something similar on the mac?

    Bill H

    Comment

    • Jerry Stuckle

      #17
      Re: Exec() function not doing as I want (OSX)

      Maarten wrote:
      Jerry Stuckle wrote:
      >Maarten wrote:
      >>Gordon Burditt wrote:
      >>>>>Readable and executable are two different things.
      >>>>
      >>>And writable is another different thing.
      >>>>
      >>>>True, but my knowledge on the permission thing is a bit limited.
      >>>>However, the permission for the specific file are:
      >>>>-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid
      >>>>>
      >>>>I guess this should allow the server to execute the program.
      >>>>
      >>>It is my experience that Apache will refuse to execute any file
      >>>that it can write. Excessive (write) permissions are just
      >>>as bad as insufficient (execute) permissions.
      >>>>
      >>>>
      >>>
      >>>
      >>I've just changed the permission of the program to 111. Still, the
      >>program is not executed.
      >>>
      >>Maarten
      >>>
      >>
      >IIRC, it has to be readable, also. I always use 550 or 555 for
      >executables.
      >>
      >How do you know it's not being executed? Are you displaying errors in
      >your browser - in your php.ini file you should have:
      >>
      >error_reportin g=E_ALL
      >display_errors =on
      >>
      >And what is the returned value from exec()?
      >>
      >
      Changed the executable's permission to 555, no change
      >
      Just double (php.ini and phpinfo() error reporting and display errors
      have the correct values. Exec() does not return a value when executed as
      below:
      >
      $discOutput = exec('/Volumes/Users/maarten/discid dev/rdisk2',
      $ooutpuut);
      >
      Both $discOutput and $ooutpuut are empty. Same as when I would fill in
      some bogus values in the function.
      >
      Maarten
      >
      >
      >
      Well, if the program can't be executed, you should get an error message
      back.

      Back to a basic question. How do you know the program is not being
      executed?

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

      Comment

      • Maarten

        #18
        Re: Exec() function not doing as I want (OSX)

        Jerry Stuckle wrote:
        Maarten wrote:
        >Jerry Stuckle wrote:
        >>Maarten wrote:
        >>>Gordon Burditt wrote:
        >>>>>>Readabl e and executable are two different things.
        >>>>>
        >>>>And writable is another different thing.
        >>>>>
        >>>>>True, but my knowledge on the permission thing is a bit limited.
        >>>>>However, the permission for the specific file are:
        >>>>>-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid
        >>>>>>
        >>>>>I guess this should allow the server to execute the program.
        >>>>>
        >>>>It is my experience that Apache will refuse to execute any file
        >>>>that it can write. Excessive (write) permissions are just
        >>>>as bad as insufficient (execute) permissions.
        >>>>>
        >>>>>
        >>>>
        >>>>
        >>>I've just changed the permission of the program to 111. Still, the
        >>>program is not executed.
        >>>>
        >>>Maarten
        >>>>
        >>>
        >>IIRC, it has to be readable, also. I always use 550 or 555 for
        >>executables .
        >>>
        >>How do you know it's not being executed? Are you displaying errors
        >>in your browser - in your php.ini file you should have:
        >>>
        >>error_reporti ng=E_ALL
        >>display_error s=on
        >>>
        >>And what is the returned value from exec()?
        >>>
        >>
        >Changed the executable's permission to 555, no change
        >>
        >Just double (php.ini and phpinfo() error reporting and display errors
        >have the correct values. Exec() does not return a value when executed
        >as below:
        >>
        > $discOutput = exec('/Volumes/Users/maarten/discid dev/rdisk2',
        >$ooutpuut);
        >>
        >Both $discOutput and $ooutpuut are empty. Same as when I would fill in
        >some bogus values in the function.
        >>
        >Maarten
        >>
        >>
        >>
        >
        Well, if the program can't be executed, you should get an error message
        back.
        >
        Back to a basic question. How do you know the program is not being
        executed?
        >
        Well, it's hard to be sure since the only thing that it does is reading
        the the TOC of a CD an return it. Since it's not enough reading to make
        my cd-rom light up and the function returns false, I assume it is not
        being executed.

        But why it behaves as it does I don't know since other functions such as
        ls and the program whois, located in the same directory as discid, are
        working fine. Also are the permissions set similar.

        Maarten

        Comment

        • Maarten

          #19
          Re: Exec() function not doing as I want (OSX)

          Bill H wrote:
          On Sep 23, 3:36 pm, Maarten <b...@blah.comw rote:
          >Bill H wrote:
          >>On Sep 19, 3:35 pm, Maarten <b...@blah.comw rote:
          >>>Howdy,
          >>>Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
          >>>I have a little problem with one function within my cd-management script.
          >>>For extracting a bit of info from my cd's I have an executable which I
          >>>execute with exec():
          >>> $discOutput = exec('./discid /dev/rdisk2');
          >>>The executable is in the same directory as the php script is in. When I
          >>>run the same line from Terminal within that same directory it gives me
          >>>the output I want, php doesn't give me any ouput at all.
          >>>Asking exec() for output on a basic function like 'ls' does return a
          >>>value, so the function is active. I guess somehow I am not pointing to
          >>>the discid executable correctly, but I don't see what is wrong.
          >>>Can someone tell me what I am doing wrong?
          >>>Thanks in advance, Maarten
          >>I had a similar issue when runnning a script in linux under apache. It
          >>took awhile for me to figure out I had to "cd" to the directory I
          >>wanted to work in and use an absolute path to the exe that is being
          >>executed. You may want to try something like this:
          >>$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
          >>Bill H
          >I changed the code to:
          >>
          > $discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
          >$ooutpuut);
          >>
          >Also have I changed the permission of discid to 555. No change, however.
          >The problem remains. Both returned variable/array are empty.
          >>
          >Maarten- Hide quoted text -
          >>
          >- Show quoted text -
          >
          Try to go around the problem to narrow it down. Do you have a
          different executable that you can put in the same location and use
          exec() on it to see if the exec() is working right, if not then you
          know that discid should not be the issue, if so then there is
          something in discid.
          >
          Bill H
          I tried already before to execute the ls command, and that one returns
          the directory listings fine. Also did I copy the whois program to the
          same directory as discid and that one is also executed nicely from
          within php, exec(). Permissions where set the same.

          The exec() function is working. But what makes discid different I don't
          know. It is working the same as all other programs in the terminal . .

          Comment

          • Bill H

            #20
            Re: Exec() function not doing as I want (OSX)

            On Sep 24, 10:27 am, Maarten <b...@blah.comw rote:
            Bill H wrote:
            On Sep 23, 3:36 pm, Maarten <b...@blah.comw rote:
            Bill H wrote:
            >On Sep 19, 3:35 pm, Maarten <b...@blah.comw rote:
            >>Howdy,
            >>Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
            >>I have a little problem with one function within my cd-management script.
            >>For extracting a bit of info from my cd's I have an executable whichI
            >>execute with exec():
            >>     $discOutput = exec('./discid /dev/rdisk2');
            >>The executable is in the same directory as the php script is in. When I
            >>run the same line from Terminal within that same directory it gives me
            >>the output I want, php doesn't give me any ouput at all.
            >>Asking exec() for output on a basic function like 'ls' does return a
            >>value, so the function is active. I guess somehow I am not pointing to
            >>the discid executable correctly, but I don't see what is wrong.
            >>Can someone tell me what I am doing wrong?
            >>Thanks in advance, Maarten
            >I had a similar issue when runnning a script in linux under apache. It
            >took awhile for me to figure out I had to "cd" to the directory I
            >wanted to work in and use an absolute path to the exe that is being
            >executed. You may want to try something like this:
            >$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
            >Bill H
            I changed the code to:
            >
                 $discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
            $ooutpuut);
            >
            Also have I changed the permission of discid to 555. No change, however.
            The problem remains. Both returned variable/array are empty.
            >
            Maarten- Hide quoted text -
            >
            - Show quoted text -
            >
            Try to go around the problem to narrow it down. Do you have a
            different executable that you can put in the same location and use
            exec() on it to see if the exec() is working right, if not then you
            know that discid should not be the issue, if so then there is
            something in discid.
            >
            Bill H
            >
            I tried already before to execute the ls command, and that one returns
            the directory listings fine. Also did I copy the whois program to the
            same directory as discid and that one is also executed nicely from
            within php, exec(). Permissions where set the same.
            >
            The exec() function is working. But what makes discid different I don't
            know. It is working the same as all other programs in the terminal . .- Hide quoted text -
            >
            - Show quoted text -
            Is discid sending out the text in a format that the exec() can get
            (STDOUT ?)? Can you pipe the results to a text file? In windows I
            would use somethign like $this = exec('discid here.txt');

            Bill H

            Comment

            • Jerry Stuckle

              #21
              Re: Exec() function not doing as I want (OSX)

              Maarten wrote:
              Jerry Stuckle wrote:
              >Maarten wrote:
              >>Jerry Stuckle wrote:
              >>>Maarten wrote:
              >>>>Gordon Burditt wrote:
              >>>>>>>Readab le and executable are two different things.
              >>>>>>
              >>>>>And writable is another different thing.
              >>>>>>
              >>>>>>True, but my knowledge on the permission thing is a bit limited.
              >>>>>>However , the permission for the specific file are:
              >>>>>>-rwxrwxrwx 1 maarten staff 18176 Sep 19 15:11 discid
              >>>>>>>
              >>>>>>I guess this should allow the server to execute the program.
              >>>>>>
              >>>>>It is my experience that Apache will refuse to execute any file
              >>>>>that it can write. Excessive (write) permissions are just
              >>>>>as bad as insufficient (execute) permissions.
              >>>>>>
              >>>>>>
              >>>>>
              >>>>>
              >>>>I've just changed the permission of the program to 111. Still, the
              >>>>program is not executed.
              >>>>>
              >>>>Maarten
              >>>>>
              >>>>
              >>>IIRC, it has to be readable, also. I always use 550 or 555 for
              >>>executable s.
              >>>>
              >>>How do you know it's not being executed? Are you displaying errors
              >>>in your browser - in your php.ini file you should have:
              >>>>
              >>>error_report ing=E_ALL
              >>>display_erro rs=on
              >>>>
              >>>And what is the returned value from exec()?
              >>>>
              >>>
              >>Changed the executable's permission to 555, no change
              >>>
              >>Just double (php.ini and phpinfo() error reporting and display errors
              >>have the correct values. Exec() does not return a value when executed
              >>as below:
              >>>
              >> $discOutput = exec('/Volumes/Users/maarten/discid dev/rdisk2',
              >>$ooutpuut);
              >>>
              >>Both $discOutput and $ooutpuut are empty. Same as when I would fill
              >>in some bogus values in the function.
              >>>
              >>Maarten
              >>>
              >>>
              >>>
              >>
              >Well, if the program can't be executed, you should get an error
              >message back.
              >>
              >Back to a basic question. How do you know the program is not being
              >executed?
              >>
              >
              Well, it's hard to be sure since the only thing that it does is reading
              the the TOC of a CD an return it. Since it's not enough reading to make
              my cd-rom light up and the function returns false, I assume it is not
              being executed.
              >
              But why it behaves as it does I don't know since other functions such as
              ls and the program whois, located in the same directory as discid, are
              working fine. Also are the permissions set similar.
              >
              Maarten
              >
              Then I would suspect the program itself is being executed but returning
              an invalid return code to exec().

              I think you need to look at what the program is doing.

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

              Comment

              • Bill H

                #22
                Re: Exec() function not doing as I want (OSX)

                On Sep 24, 10:27 am, Maarten <b...@blah.comw rote:
                Bill H wrote:
                On Sep 23, 3:36 pm, Maarten <b...@blah.comw rote:
                Bill H wrote:
                >On Sep 19, 3:35 pm, Maarten <b...@blah.comw rote:
                >>Howdy,
                >>Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
                >>I have a little problem with one function within my cd-management script.
                >>For extracting a bit of info from my cd's I have an executable whichI
                >>execute with exec():
                >>     $discOutput = exec('./discid /dev/rdisk2');
                >>The executable is in the same directory as the php script is in. When I
                >>run the same line from Terminal within that same directory it gives me
                >>the output I want, php doesn't give me any ouput at all.
                >>Asking exec() for output on a basic function like 'ls' does return a
                >>value, so the function is active. I guess somehow I am not pointing to
                >>the discid executable correctly, but I don't see what is wrong.
                >>Can someone tell me what I am doing wrong?
                >>Thanks in advance, Maarten
                >I had a similar issue when runnning a script in linux under apache. It
                >took awhile for me to figure out I had to "cd" to the directory I
                >wanted to work in and use an absolute path to the exe that is being
                >executed. You may want to try something like this:
                >$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
                >Bill H
                I changed the code to:
                >
                     $discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
                $ooutpuut);
                >
                Also have I changed the permission of discid to 555. No change, however.
                The problem remains. Both returned variable/array are empty.
                >
                Maarten- Hide quoted text -
                >
                - Show quoted text -
                >
                Try to go around the problem to narrow it down. Do you have a
                different executable that you can put in the same location and use
                exec() on it to see if the exec() is working right, if not then you
                know that discid should not be the issue, if so then there is
                something in discid.
                >
                Bill H
                >
                I tried already before to execute the ls command, and that one returns
                the directory listings fine. Also did I copy the whois program to the
                same directory as discid and that one is also executed nicely from
                within php, exec(). Permissions where set the same.
                >
                The exec() function is working. But what makes discid different I don't
                know. It is working the same as all other programs in the terminal . .- Hide quoted text -
                >
                - Show quoted text -
                Google groups ate my reply from earlier it appears. Is that program
                sending to STDOUT (I believe that is what exec() looks at)?

                How about piping, can you do that in Mac OSX? ( ie $this=exec('dis cid
                here.txt'); ) Does it output to the here.txt?
                Bill H

                Comment

                • Captain Paralytic

                  #23
                  Re: Exec() function not doing as I want (OSX)

                  On 24 Sep, 21:50, Bill H <b...@ts1000.us wrote:
                  On Sep 24, 10:27 am, Maarten <b...@blah.comw rote:
                  >
                  >
                  >
                  Bill H wrote:
                  On Sep 23, 3:36 pm, Maarten <b...@blah.comw rote:
                  >Bill H wrote:
                  >>On Sep 19, 3:35 pm, Maarten <b...@blah.comw rote:
                  >>>Howdy,
                  >>>Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
                  >>>I have a little problem with one function within my cd-management script.
                  >>>For extracting a bit of info from my cd's I have an executable which I
                  >>>execute with exec():
                  >>>     $discOutput = exec('./discid /dev/rdisk2');
                  >>>The executable is in the same directory as the php script is in. When I
                  >>>run the same line from Terminal within that same directory it gives me
                  >>>the output I want, php doesn't give me any ouput at all.
                  >>>Asking exec() for output on a basic function like 'ls' does returna
                  >>>value, so the function is active. I guess somehow I am not pointing to
                  >>>the discid executable correctly, but I don't see what is wrong.
                  >>>Can someone tell me what I am doing wrong?
                  >>>Thanks in advance, Maarten
                  >>I had a similar issue when runnning a script in linux under apache.It
                  >>took awhile for me to figure out I had to "cd" to the directory I
                  >>wanted to work in and use an absolute path to the exe that is being
                  >>executed. You may want to try something like this:
                  >>$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
                  >>Bill H
                  >I changed the code to:
                  >
                  >     $discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
                  >$ooutpuut);
                  >
                  >Also have I changed the permission of discid to 555. No change, however.
                  >The problem remains. Both returned variable/array are empty.
                  >
                  >Maarten- Hide quoted text -
                  >
                  >- Show quoted text -
                  >
                  Try to go around the problem to narrow it down. Do you have a
                  different executable that you can put in the same location and use
                  exec() on it to see if the exec() is working right, if not then you
                  know that discid should not be the issue, if so then there is
                  something in discid.
                  >
                  Bill H
                  >
                  I tried already before to execute the ls command, and that one returns
                  the directory listings fine. Also did I copy the whois program to the
                  same directory as discid and that one is also executed nicely from
                  within php, exec(). Permissions where set the same.
                  >
                  The exec() function is working. But what makes discid different I don't
                  know. It is working the same as all other programs in the terminal . .-Hide quoted text -
                  >
                  - Show quoted text -
                  >
                  Google groups ate my reply from earlier it appears. Is that program
                  sending to STDOUT (I believe that is what exec() looks at)?
                  >
                  How about piping, can you do that in Mac OSX? ( ie $this=exec('dis cid
                  >
                  here.txt'); ) Does it output to the here.txt?
                  >
                  Bill H
                  | is piping, is redirection.

                  Comment

                  • Bill H

                    #24
                    Re: Exec() function not doing as I want (OSX)

                    On Sep 25, 6:31 am, Captain Paralytic <paul_laut...@y ahoo.comwrote:
                    On 24 Sep, 21:50, Bill H <b...@ts1000.us wrote:
                    >
                    >
                    >
                    >
                    >
                    On Sep 24, 10:27 am, Maarten <b...@blah.comw rote:
                    >
                    Bill H wrote:
                    On Sep 23, 3:36 pm, Maarten <b...@blah.comw rote:
                    Bill H wrote:
                    >On Sep 19, 3:35 pm, Maarten <b...@blah.comw rote:
                    >>Howdy,
                    >>Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2..6) and
                    >>I have a little problem with one function within my cd-management script.
                    >>For extracting a bit of info from my cd's I have an executable which I
                    >>execute with exec():
                    >>     $discOutput = exec('./discid /dev/rdisk2');
                    >>The executable is in the same directory as the php script is in.When I
                    >>run the same line from Terminal within that same directory it gives me
                    >>the output I want, php doesn't give me any ouput at all.
                    >>Asking exec() for output on a basic function like 'ls' does return a
                    >>value, so the function is active. I guess somehow I am not pointing to
                    >>the discid executable correctly, but I don't see what is wrong.
                    >>Can someone tell me what I am doing wrong?
                    >>Thanks in advance, Maarten
                    >I had a similar issue when runnning a script in linux under apache. It
                    >took awhile for me to figure out I had to "cd" to the directory I
                    >wanted to work in and use an absolute path to the exe that is being
                    >executed. You may want to try something like this:
                    >$discOutput = exec('cd /dev/rdisk2;[fullpathto discid]/discid');
                    >Bill H
                    I changed the code to:
                    >
                         $discOutput = exec('cd /dev/rdisk2; /Volumes/Users/maarten/discid',
                    $ooutpuut);
                    >
                    Also have I changed the permission of discid to 555. No change, however.
                    The problem remains. Both returned variable/array are empty.
                    >
                    Maarten- Hide quoted text -
                    >
                    - Show quoted text -
                    >
                    Try to go around the problem to narrow it down. Do you have a
                    different executable that you can put in the same location and use
                    exec() on it to see if the exec() is working right, if not then you
                    know that discid should not be the issue, if so then there is
                    something in discid.
                    >
                    Bill H
                    >
                    I tried already before to execute the ls command, and that one returns
                    the directory listings fine. Also did I copy the whois program to the
                    same directory as discid and that one is also executed nicely from
                    within php, exec(). Permissions where set the same.
                    >
                    The exec() function is working. But what makes discid different I don't
                    know. It is working the same as all other programs in the terminal . ..- Hide quoted text -
                    >
                    - Show quoted text -
                    >
                    Google groups ate my reply from earlier it appears. Is that program
                    sending to STDOUT (I believe that is what exec() looks at)?
                    >
                    How about piping, can you do that in Mac OSX? ( ie $this=exec('dis cid
                    >
                    here.txt'); ) Does it output to the here.txt?
                    >
                    Bill H
                    >
                    | is piping, is redirection.- Hide quoted text -
                    >
                    - Show quoted text -
                    You are right - I meant redirection

                    Bill H

                    Comment

                    Working...