Home > Archive > PERL Miscellaneous > July 2005 > trouble with Archive::Tar : Can not read compressed format in tar-mode
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
trouble with Archive::Tar : Can not read compressed format in tar-mode
|
|
| benoit Guyon 2005-07-26, 4:06 am |
| 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 2005-07-26, 9:02 am |
| 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" <REMOVEMEbguyon1@gfi.frREMOVEME> wrote in message
news:dc4tta$u5k$1@news1.completel.net...
> 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
|
|
|
|
|