Re: Archive::Tar

2002-09-11 Thread Randy J. Ray

Most of the replies have focused on how to do this with external calls to tar 
or cpio, without actually addressing the original writer's problem, how to do 
it with Archive::Tar.

The first respondent noted that Archive::Tar doesn't do wildcarding. Or, as it 
is called in the Perl docs, globbing. What you need to do is create the file 
list yourself, and pass it to the call. There are a variety of ways you can do 
this: you can use the File::Find module to build up a list of files, or since 
you seem to be concerned with just the one directory you can use Perl's 
built-in globbing functionality with <*> (or with glob(), if you prefer). Look 
to the perlop manpage (under I/O Operators) for the <*> syntax, or perlfunc 
for glob().

Randy
-- 
---
Randy J. Ray | Men occasionally stumble over the truth, but most of them
[EMAIL PROTECTED] | pick themselves up and hurry off as if nothing had happened.
+1 650 930-9097  |   -- Sir Winston Churchill



Re: Archive::Tar

2002-09-11 Thread Steven Lembark



-- "Anthony E." <[EMAIL PROTECTED]>

>> How can I get this to tar the entire backup
>> directory? And if I wanted to
>> say pic out all file based on extensions later on
>> like .pl *.pl how to do
>> that as well with this?


gnu cpio will write tar:

find $dir | cpio -ov -Htar | gzip --best > /blah/$dir.tar.gz;

or

find $dir -name '*.pl' | cpio -ov -Htar | gzip ...

the -Hcrc puts a 32-bit crc on the files for better error
checking, etc:

find $dir -name '*.pl' | cpio -ov -Hcrc | gzip ...

Nice thing about cpio vs. tar for this is that if tar fails
to write it can exit zero after successfully telling you that
it failed; cpio croaks and exits non-zero immediatly if it
detects an error on writing or extract.

--
Steven Lembark   2930 W. Palmer
Workhorse Computing   Chicago, IL 60647
+1 800 762 1582



Re: Archive::Tar

2002-09-11 Thread Anthony E.

not sure about Archive::Tar...but here's the command
line, you can call this in your perl script.

"tar czf ./test.tar.gz ./backups --files-from
./include.txt"

If you wanted to include only *.pl, just put "*.pl" in
your include.txt file. (same goes for exclusion, use
--exlude-from instead)

--- [EMAIL PROTECTED] wrote:
> 
> Hello,
> 
> I am trying to use the following program to archive
> directories of large
> files but I can not get any wildcard combination to
> work:
> 
> #!/usr/bin/perl
> use Archive::Tar;
> 
> Archive::Tar->create_archive ("test.tar", 9,
> "backup/*.*");
> print join "\n", Archive::Tar->list_archive
> ("test.tar"), "";
> 
> How can I get this to tar the entire backup
> directory? And if I wanted to
> say pic out all file based on extensions later on
> like .pl *.pl how to do
> that as well with this?
> 
> Thanks,
> John
> 


__
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
http://dir.remember.yahoo.com/tribute



Re: Archive::Tar

2002-09-11 Thread Lupe Christoph

Waay offtopic. But here goes:

On Wednesday, 2002-09-11 at 04:06:20 -0500, [EMAIL PROTECTED] wrote:

> I am trying to use the following program to archive directories of large
> files but I can not get any wildcard combination to work:

Archive::Tar does not do Wildcards.

> #!/usr/bin/perl
> use Archive::Tar;

> Archive::Tar->create_archive ("test.tar", 9, "backup/*.*");

>From perldoc Archive::Tar:
   The remaining arguments list the files to be included
   in the tar file.  These files must all exist.  Any
   files which don\'t exist or can\'t be read are
   silently ignored.

I.e. You would add a file *named* "backup/*.*".

> How can I get this to tar the entire backup directory? And if I wanted to
> say pic out all file based on extensions later on like .pl *.pl how to do
> that as well with this?

Combine this with File::Find:

my $tar = Archive::Tar->new();
find({ wanted => \&wanted, no_chdir => 1}, "backup");
$tar->write("test.tar.gz", 9);

sub wanted {
  return unless /\.pl$/ and -f $_; # Only files named *.pl
  print "Adding $_\n";
  $tar->add_files($_);


You could use glob() to expand "*.*", but you still wouldn't get any
recursion into subdirecties. With File::Find you can use any test you
like. Note that $_ contains the file*path* starting at "backup" with the
no_chdir option. This differs from normal behaviour (i.e. with no_chdir
unset).

HTH,
Lupe Christoph
-- 
| [EMAIL PROTECTED]   |   http://www.lupe-christoph.de/ |
| Big Misunderstandings #6398: The Titanic was not supposed to be|
| unsinkable. The designer had a speech impediment. He said: "I have |
| thith great unthinkable conthept ..."  |



Archive::Tar

2002-09-11 Thread john.buwa


Hello,

I am trying to use the following program to archive directories of large
files but I can not get any wildcard combination to work:

#!/usr/bin/perl
use Archive::Tar;

Archive::Tar->create_archive ("test.tar", 9, "backup/*.*");
print join "\n", Archive::Tar->list_archive ("test.tar"), "";

How can I get this to tar the entire backup directory? And if I wanted to
say pic out all file based on extensions later on like .pl *.pl how to do
that as well with this?

Thanks,
John