trouble with Archive::Tar : Can not read compressed format in tar-mode

Discussion in 'Perl Misc' started by benoit Guyon, Jul 26, 2005.

  1. benoit Guyon

    benoit Guyon Guest

    hello,

    i have a problem when reading a tar.Z file :

    the code is :

    # ----------------------------------------------------
    #!/usr/local/bin/perl -w

    use strict;
    use warnings;
    use Archive::Tar;

    my $arch_name_tar_Z = 'myfile.tar.Z';

    my $tar = Archive::Tar->new;
    $tar->read($arch_name_tar_Z, 1)
    or die("*** ERROR read Archive::Tar: $!");
    # ----------------------------------------------------

    and the error is :
    Can not read compressed format in tar-mode

    i tried the commands :
    tar -xzvf myfile.tar.Z -> OK (i get valid files)
    uncompress myfile.tar.Z -> OK (i get a valid myfile.tar file)
    gunzip myfile.tar.Z -> OK (i get a valid myfile.tar file)

    i checked the code in Tar.pm, and found

    unless( $read++ ) {
    my $gzip = GZIP_MAGIC_NUM;
    if( $chunk =~ /$gzip/ ) {
    $self->_error( qq[Can not read compressed format in tar-mode] );
    return;
    }
    }

    is my archive compressed with an exotic compressor ? why can the batch
    tar command successfully do the job ?

    does somebody have an idea to help me ?

    best regards

    benoit

    PS : i tried to build a IO::Zlib Handle on the file (success) and then
    to pass it to the Archive::Tar->read function, but i get the same error
    message.

    PS 2 : Archive::Tar->can_handle_compressed_files gives true
     
    benoit Guyon, Jul 26, 2005
    #1
    1. Advertising

  2. Archive::Tar can optionally make use of IO::Zlib to access compressed tar
    files that have been compressed with gzip. The problem is your tar file has
    been compressed with something different, namely the Unix compress program.

    Try opening Archive::Tar like this

    my $arch_name_tar_Z = 'myfile.tar.Z';
    open F, "uncompress -c $arch_name_tar_Z |";
    my $tar = Archive::Tar->new(*F);

    Paul

    "benoit Guyon" <> wrote in message
    news:dc4tta$u5k$...
    > hello,
    >
    > i have a problem when reading a tar.Z file :
    >
    > the code is :
    >
    > # ----------------------------------------------------
    > #!/usr/local/bin/perl -w
    >
    > use strict;
    > use warnings;
    > use Archive::Tar;
    >
    > my $arch_name_tar_Z = 'myfile.tar.Z';
    >
    > my $tar = Archive::Tar->new;
    > $tar->read($arch_name_tar_Z, 1)
    > or die("*** ERROR read Archive::Tar: $!");
    > # ----------------------------------------------------
    >
    > and the error is :
    > Can not read compressed format in tar-mode
    >
    > i tried the commands :
    > tar -xzvf myfile.tar.Z -> OK (i get valid files)
    > uncompress myfile.tar.Z -> OK (i get a valid myfile.tar file)
    > gunzip myfile.tar.Z -> OK (i get a valid myfile.tar file)
    >
    > i checked the code in Tar.pm, and found
    >
    > unless( $read++ ) {
    > my $gzip = GZIP_MAGIC_NUM;
    > if( $chunk =~ /$gzip/ ) {
    > $self->_error( qq[Can not read compressed format in tar-mode] );
    > return;
    > }
    > }
    >
    > is my archive compressed with an exotic compressor ? why can the batch
    > tar command successfully do the job ?
    >
    > does somebody have an idea to help me ?
    >
    > best regards
    >
    > benoit
    >
    > PS : i tried to build a IO::Zlib Handle on the file (success) and then
    > to pass it to the Archive::Tar->read function, but i get the same error
    > message.
    >
    > PS 2 : Archive::Tar->can_handle_compressed_files gives true
     
    Paul Marquess, Jul 26, 2005
    #2
    1. Advertising

  3. benoit Guyon

    benoit Guyon Guest

    Re: trouble with Archive::Tar : Can not read compressed format intar-mode

    thank you for the response

    i used that code to correct my problem :

    qx{gunzip $arch_name_tar_z};

    and then sent the new file to Archive::Tar (with success)

    oddly, the archive must have been compressed with "compress", but gunzip
    does the job well

    Benoit

    Paul Marquess a écrit :
    > Archive::Tar can optionally make use of IO::Zlib to access compressed tar
    > files that have been compressed with gzip. The problem is your tar file has
    > been compressed with something different, namely the Unix compress program.
    >
    > Try opening Archive::Tar like this
    >
    > my $arch_name_tar_Z = 'myfile.tar.Z';
    > open F, "uncompress -c $arch_name_tar_Z |";
    > my $tar = Archive::Tar->new(*F);
    >
    > Paul
    >
    > "benoit Guyon" <> wrote in message
    > news:dc4tta$u5k$...
    >
    >>hello,
    >>
    >>i have a problem when reading a tar.Z file :
    >>
    >>the code is :
    >>
    >># ----------------------------------------------------
    >>#!/usr/local/bin/perl -w
    >>
    >>use strict;
    >>use warnings;
    >>use Archive::Tar;
    >>
    >>my $arch_name_tar_Z = 'myfile.tar.Z';
    >>
    >>my $tar = Archive::Tar->new;
    >>$tar->read($arch_name_tar_Z, 1)
    >> or die("*** ERROR read Archive::Tar: $!");
    >># ----------------------------------------------------
    >>
    >>and the error is :
    >>Can not read compressed format in tar-mode
    >>
    >>i tried the commands :
    >>tar -xzvf myfile.tar.Z -> OK (i get valid files)
    >>uncompress myfile.tar.Z -> OK (i get a valid myfile.tar file)
    >>gunzip myfile.tar.Z -> OK (i get a valid myfile.tar file)
    >>
    >>i checked the code in Tar.pm, and found
    >>
    >>unless( $read++ ) {
    >> my $gzip = GZIP_MAGIC_NUM;
    >> if( $chunk =~ /$gzip/ ) {
    >> $self->_error( qq[Can not read compressed format in tar-mode] );
    >> return;
    >> }
    >>}
    >>
    >>is my archive compressed with an exotic compressor ? why can the batch
    >>tar command successfully do the job ?
    >>
    >>does somebody have an idea to help me ?
    >>
    >>best regards
    >>
    >>benoit
    >>
    >>PS : i tried to build a IO::Zlib Handle on the file (success) and then
    >>to pass it to the Archive::Tar->read function, but i get the same error
    >>message.
    >>
    >>PS 2 : Archive::Tar->can_handle_compressed_files gives true

    >
    >
    >
     
    benoit Guyon, Jul 26, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. labrach

    Archive::Tar on win32

    labrach, Sep 16, 2004, in forum: Perl
    Replies:
    1
    Views:
    714
    Ian Sedwell
    Sep 21, 2004
  2. John Salerno
    Replies:
    3
    Views:
    709
    John Salerno
    Aug 10, 2006
  3. Austin Ziegler

    [ANN] Archive::Tar::Minitar 0.5.0

    Austin Ziegler, Sep 7, 2004, in forum: Ruby
    Replies:
    3
    Views:
    124
    Chris Ruzin
    Sep 7, 2004
  4. Terry Michaels
    Replies:
    0
    Views:
    86
    Terry Michaels
    Oct 17, 2010
  5. Replies:
    2
    Views:
    199
Loading...

Share This Page