exec() and zip

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

    exec() and zip

    I have zip.exe in my PATH on a windows XP box. Additionally, I have a script
    which, if I execute locally with

    php myfile.php

    it runs fine. However, when I call myfile.php remotely with a web browser,
    it canot seem to find zip.exe. Below are the releveant code snippets. TIA,
    Ike

    exec( "zip -mj \backups\temp\c ookbook.zip \backups\temp\c ookbook.sql 2>&1",
    $output, $res );
    if( $res 0 ) {
    error( true,"COMPRESSI ON FAILED\n".implo de( "\n", $output));

    COMPRESSION FAILED
    The system cannot execute the specified program.


  • Rudi Menter

    #2
    Re: exec() and zip

    Ike wrote:
    exec( "zip -mj \backups\temp\c ookbook.zip \backups\temp\c ookbook.sql 2>&1",
    $output, $res );
    if( $res 0 ) {
    error( true,"COMPRESSI ON FAILED\n".implo de( "\n", $output));
    >
    COMPRESSION FAILED
    The system cannot execute the specified program.
    Ok, zip has been run since the system cannot produce the message
    COMPRESSION FAILED from itself, so you need to check the arguments.

    Regards
    --

    Comment

    • Ike

      #3
      Re: exec() and zip


      "Rudi Menter" <spamcowgirl@sp amgourmet.comwr ote in message
      news:1kq7rhim8s y9$.1h5mu2a3zbs bq.dlg@40tude.n et...
      Ike wrote:
      >
      >exec( "zip -mj \backups\temp\c ookbook.zip \backups\temp\c ookbook.sql
      >2>&1",
      >$output, $res );
      >if( $res 0 ) {
      > error( true,"COMPRESSI ON FAILED\n".implo de( "\n", $output));
      >>
      >COMPRESSION FAILED
      >The system cannot execute the specified program.
      >
      Ok, zip has been run since the system cannot produce the message
      COMPRESSION FAILED from itself, so you need to check the arguments.
      >
      Regards
      --
      Rudi,
      Do you mean the arguments to exec ? Why then would this run in
      localmode? -Ike


      Comment

      • Rudi Menter

        #4
        Re: exec() and zip

        Ike write:
        >>exec( "zip -mj \backups\temp\c ookbook.zip \backups\temp\c ookbook.sql
        >>2>&1",
        >>$output, $res );
        >>if( $res 0 ) {
        >> error( true,"COMPRESSI ON FAILED\n".implo de( "\n", $output));
        >>>
        >>COMPRESSION FAILED
        >>The system cannot execute the specified program.
        >>
        >Ok, zip has been run since the system cannot produce the message
        >COMPRESSION FAILED from itself, so you need to check the arguments.
        Do you mean the arguments to exec?
        Nope, but to "zip.exe"
        Why then would this run in localmode? -Ike
        Perhaps you need to set the current working directory properly
        or use absolute paths, i.e. those who begin with a drive letter
        like c:\some\directo ry\cookook...

        I am sure, this will solve it!

        Regards
        --

        Comment

        • Jerry Stuckle

          #5
          Re: exec() and zip

          Ike wrote:
          I have zip.exe in my PATH on a windows XP box. Additionally, I have a script
          which, if I execute locally with
          >
          php myfile.php
          >
          it runs fine. However, when I call myfile.php remotely with a web browser,
          it canot seem to find zip.exe. Below are the releveant code snippets. TIA,
          Ike
          >
          exec( "zip -mj \backups\temp\c ookbook.zip \backups\temp\c ookbook.sql 2>&1",
          $output, $res );
          if( $res 0 ) {
          error( true,"COMPRESSI ON FAILED\n".implo de( "\n", $output));
          >
          COMPRESSION FAILED
          The system cannot execute the specified program.
          >
          >
          Does the userid the web server is running under have access to zip?
          Check your security settings.

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

          Comment

          • Ike

            #6
            Re: exec() and zip


            "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
            news:4qudnWQTEa RGXc_YnZ2dnUVZ_ oGdnZ2d@comcast .com...
            Does the userid the web server is running under have access to zip? Check
            your security settings.
            >
            Hmm, it's apache 1.3.x for Windows -- I can't really tell (there is no
            ..htaccss in the directory where zip.exe is, which is on the windows path).
            What if I put it in c:\backup and called it explicitly like c:\backup\zip ?


            Comment

            • Chuck Anderson

              #7
              Re: exec() and zip

              Ike wrote:
              "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
              news:4qudnWQTEa RGXc_YnZ2dnUVZ_ oGdnZ2d@comcast .com...
              >
              >
              >Does the userid the web server is running under have access to zip? Check
              >your security settings.
              >>
              >>
              >
              Hmm, it's apache 1.3.x for Windows -- I can't really tell (there is no
              .htaccss in the directory where zip.exe is, which is on the windows path).
              What if I put it in c:\backup and called it explicitly like c:\backup\zip ?
              >
              >
              >
              I've used Winzip on my WAMP setup - Windows XP (and then switched to
              7zip - much easier).

              To get zip to work from an exec call, I had to open the Services window
              (Run - services.msc) - select Apache - click on Properties - go to the
              Log On tab and then check "allow service to interact with the desktop."
              (I've been flamed for admitting to doing that, too. ?)

              After learning more, I downloaded 7-zip (free), which comes with a very
              nice command line interface and I switched to using that. It works much
              nicer (and it can create .zip format).

              --
              *************** **************
              Chuck Anderson • Boulder, CO

              *************** **************

              Comment

              • Ike

                #8
                Re: exec() and zip


                "Chuck Anderson" <websiteaddress @seemy.sigwrote in message
                news:i8ydnWT7Ho UvIc7YnZ2dnUVZ_ vednZ2d@comcast .com...
                >I had to open the Services window (Run - services.msc) - select Apache -
                >click on Properties - go to the Log On tab and then check "allow service to
                >interact with the desktop." (I've been flamed for admitting to doing that,
                >too. ?)
                Any idea why you got flamed for that? I'm just wondering if/what kind of
                security risk this would have created. Thanks, Ike


                Comment

                • Chuck Anderson

                  #9
                  Re: exec() and zip

                  Ike wrote:
                  "Chuck Anderson" <websiteaddress @seemy.sigwrote in message
                  news:i8ydnWT7Ho UvIc7YnZ2dnUVZ_ vednZ2d@comcast .com...
                  >
                  >I had to open the Services window (Run - services.msc) - select Apache -
                  >click on Properties - go to the Log On tab and then check "allow service to
                  >interact with the desktop." (I've been flamed for admitting to doing that,
                  >too. ?)
                  >>
                  >
                  Any idea why you got flamed for that? I'm just wondering if/what kind of
                  security risk this would have created. Thanks, Ike
                  >
                  >
                  >
                  No security risk, I was just told that it was "bad form" (to put it
                  mildly) to run a GUI app from a web request. And the flamers were
                  confused about how I was using the Php script.

                  If all you want to do is zip a file, I suggest you try 7-zip (unless you
                  have the command line version of WinZip).

                  --
                  *************** **************
                  Chuck Anderson • Boulder, CO

                  *************** **************

                  Comment

                  Working...