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" <[EMAIL PROTECTED]> 
02/24/2006 09:22 PM

To
Irfan J Sayed/India/[EMAIL PROTECTED]
cc
beginners@perl.org
Subject
Re: tar command






On 2/24/06, Irfan J Sayed <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Reply via email to