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

B

benoit Guyon

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
 
P

Paul Marquess

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
 
B

benoit Guyon

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

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top