Unzip a tar.gz file?

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

    #1

    Unzip a tar.gz file?

    OK, so let's say I've downloaded a file using the FTP lib and have it
    sitting on my server in the current script's directory:

    <?php
    $projects = ftp_nlist($c, ".");
    ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
    // Local file is $projects[0]
    ?>

    How could I uncompress that archive into the local directory, assuming
    a tar.gz filetype? I'm lost at sea in these docs: http://us3.php.net/manual/en/book.zlib.php

    Thomas
  • Jerry Stuckle

    #2
    Re: Unzip a tar.gz file?

    703designs wrote:
    OK, so let's say I've downloaded a file using the FTP lib and have it
    sitting on my server in the current script's directory:
    >
    <?php
    $projects = ftp_nlist($c, ".");
    ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
    // Local file is $projects[0]
    ?>
    >
    How could I uncompress that archive into the local directory, assuming
    a tar.gz filetype? I'm lost at sea in these docs: http://us3.php.net/manual/en/book.zlib.php
    >
    Thomas
    >
    man tar (on Unix/Linux).

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

    Comment

    • Curtis

      #3
      Re: Unzip a tar.gz file?

      703designs wrote:
      OK, so let's say I've downloaded a file using the FTP lib and have it
      sitting on my server in the current script's directory:
      >
      <?php
      $projects = ftp_nlist($c, ".");
      ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
      // Local file is $projects[0]
      ?>
      >
      How could I uncompress that archive into the local directory, assuming
      a tar.gz filetype? I'm lost at sea in these docs: http://us3.php.net/manual/en/book.zlib.php
      >
      Thomas
      If you're not on a Unix, you may want to check out the PEAR
      Archive_Tar class. You have to untar the file before using zlib.
      Perhaps the class takes care of the compression, too; I haven't used
      it, myself.

      <URL:http://pear.php.net/package/Archive_Tar>

      If you're having trouble with the PHP manual concerning gzip (or
      anything, really), I suggest you read the user comments, as well.
      There may be existing contributions that solve your problem exactly.
      If not, stick with it, and practice by writing code until it starts to
      make sense.

      --
      Curtis

      Comment

      • 703designs

        #4
        Re: Unzip a tar.gz file?

        So the only way to untar it is to use a system() call?

        On Oct 23, 4:42 am, Curtis <dye...@gmail.c omwrote:
        703designs wrote:
        OK, so let's say I've downloaded a file using the FTP lib and have it
        sitting on my server in the current script's directory:
        >
        <?php
            $projects = ftp_nlist($c, ".");
            ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
            // Local file is $projects[0]
        ?>
        >
        How could I uncompress that archive into the local directory, assuming
        a tar.gz filetype? I'm lost at sea in these docs:http://us3.php.net/manual/en/book.zlib.php
        >
        Thomas
        >
        If you're not on a Unix, you may want to check out the PEAR
        Archive_Tar class. You have to untar the file before using zlib.
        Perhaps the class takes care of the compression, too; I haven't used
        it, myself.
        >
        <URL:http://pear.php.net/package/Archive_Tar>
        >
        If you're having trouble with the PHP manual concerning gzip (or
        anything, really), I suggest you read the user comments, as well.
        There may be existing contributions that solve your problem exactly.
        If not, stick with it, and practice by writing code until it starts to
        make sense.
        >
        --
        Curtis

        Comment

        • 703designs

          #5
          Re: Unzip a tar.gz file?

          On Oct 23, 7:37 am, 703designs <thomasmal...@g mail.comwrote:
          So the only way to untar it is to use a system() call?
          >
          On Oct 23, 4:42 am, Curtis <dye...@gmail.c omwrote:
          >
          703designs wrote:
          OK, so let's say I've downloaded a file using the FTP lib and have it
          sitting on my server in the current script's directory:
          >
          <?php
              $projects = ftp_nlist($c, ".");
              ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
              // Local file is $projects[0]
          ?>
          >
          How could I uncompress that archive into the local directory, assuming
          a tar.gz filetype? I'm lost at sea in these docs:http://us3.php.net/manual/en/book.zlib.php
          >
          Thomas
          >
          If you're not on a Unix, you may want to check out the PEAR
          Archive_Tar class. You have to untar the file before using zlib.
          Perhaps the class takes care of the compression, too; I haven't used
          it, myself.
          >
          <URL:http://pear.php.net/package/Archive_Tar>
          >
          If you're having trouble with the PHP manual concerning gzip (or
          anything, really), I suggest you read the user comments, as well.
          There may be existing contributions that solve your problem exactly.
          If not, stick with it, and practice by writing code until it starts to
          make sense.
          >
          --
          Curtis
          >
          >
          Ah, the PEAR class works very well. This seems reliable.

          Comment

          Working...