Re: tar command



Hi All,

Thanks for mail

I am using following script for backup of clearcase data. the problem is
that it executes upto the tar command but when it comes to the zip command
it simply hangs.

could u plz help me out

regards
irfan.


#!/usr/bin/perl -w

# This script takes the backup of vobs , make the tar and zip
# copy the zipped file in tape and keep it in a safe location.

# This is a daily backup procedure and needs to be started at midnight.

my ($CT,$vob_tag,$cc);

$CT = "/usr/atria/bin/cleartool";
$cc = "/opt/rational/clearcase/etc/clearcase";

@vob_list = (
"/vobs/second",
);

# Lock the every vob

foreach $vob_tag (@vob_list)
{

`$CT lock vob:$vob_tag`;

}

# Stop the clearcase to ensure no any file is open for writing

`$cc stop`;

# Taring the vob storage directory

system ("tar -cpvf /vobstg.tar /vobstg");


# Zip the tar file

system ("gzip vobstg.tar");


# start the clearacse

`$cc start`;

# unLock the every vob

foreach $vob_tag (@vob_list)
{

`$CT unlock vob:$vob_tag`;

}






Regards
Irfan Sayed





"Chas Owens" <chas.owens@xxxxxxxxx>
02/24/2006 09:22 PM

To
Irfan J Sayed/India/IBM@IBMIN
cc
beginners@xxxxxxxx
Subject
Re: tar command






On 2/24/06, Irfan J Sayed <irfsayed@xxxxxxxxxx> wrote:
Hi All,

I need to execute unix tar command thru perl file
can somebody helps me out in this regard

Regards
Irfan Sayed


You might look at Tar
(http://search.cpan.org/~cdybed/Tar-0.04/Tar.pm), Archive::Tar
(http://search.cpan.org/~kane/Archive-Tar-1.28/lib/Archive/Tar.pm),
and Archive::TarGzip
(
http://search.cpan.org/~softdia/Archive-TarGzip-0.03/lib/Archive/TarGzip.pm
)
if you need to access the tar files programmaticly. If you just want
to use the tar executable on your system then you can use system, the
backquote operator (AKA qx()), or a combination of fork and exec.

Assuming you do not need anything but a return value you can say

system("tar cfz foo.tgz /foo/*");

If you want to capture the stdout you can say

my @lines = `tar cvfz foo.tgz /foo/*`;

or

my @lines = qx(tar cvfz foo.tgz /foo/*);

If you need it to run concurrently with the Perl script you can say

$SIG{CHLD} = 'autoreap';

my $fork = fork();
die "could not fork:$!" unless defined $fork;
if ($fork) { #parent code
print "kicked off a child whose pid is $fork\n";
} else {
exec('tar', 'cvfz', '/foo/*');
}

I would suggest reading up on system, fork, exec, and the qx()
operator before doing anything.

perldoc -f system
perldoc -f fork
perldoc -f exec
perldoc perlop

or

http://perldoc.perl.org/functions/system.html
http://perldoc.perl.org/functions/fork.html
http://perldoc.perl.org/functions/exec.html
http://perldoc.perl.org/perlop.html

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>





Relevant Pages

  • Re: tar over 2 GB - how to backup it?
    ... I have seen cases of v5.1 tar being able to back up 10GB Oracle files ... 1.The tar command is not enabled for files greater than 2 Gig in size ... due to limitations imposed by XPG/4 and POSIX.2 standards. ...
    (comp.unix.aix)
  • Re: tar: cannot open: /dev/rct0
    ... | I am having a problem with a series of identically configured Dell machines ... | when I issue a specific tar command the first time after a fresh boot. ...
    (comp.unix.sco.misc)
  • tar: cannot open: /dev/rct0
    ... I am having a problem with a series of identically configured Dell machines ... when I issue a specific tar command the first time after a fresh boot. ... I can then issue the same tar command, ...
    (comp.unix.sco.misc)
  • tar: cannot open: /dev/rct0
    ... I am having a problem with a series of identically configured Dell machines ... when I issue a specific tar command the first time after a fresh boot. ... I can then issue the same tar command, ...
    (comp.unix.sco.misc)
  • Re: There is not enough memory available now.
    ... while i run tar command for backup a filesystems; ... I restore the tape data to other directory...but some file is lost ... the tar command uses a temporary file (the ... file) and maintains in memory a table of files with several links. ...
    (comp.unix.aix)