Hans,

Here is one way to do it:

#!/usr/bin/perl -w
use strict;
use POSIX;

# variable declarations
my $dir_name= "samples";
my $source_dir = "$ENV{HOME}/work_area/scripts";
my $gdir;

        print "Changing current directory to...Source dir
......$source_dir\n";
        chdir "$source_dir";

# fetch and print the value of current working directory
        
        print " Current working directory is : ", getcwd(), "\n";
      $gdir = getcwd();

# Tar the files in desired directory ( The ./$dir_name helps preserve
# relative pathnames for the files

        print "Tar-ing file into Source dir ......$source_dir\n";
        system("/usr/bin/tar -cvf $dir_name.tar ./$dir_name");


- Ravi

-----Original Message-----
From: Baartmans, Hans [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 23, 2001 7:22 AM
To: '[EMAIL PROTECTED]'
Subject: Perform a tar command on a directory


Does anyone have a good suggestion how to go about creating a tar ball of a
directory from within a Perl script?  I considered doing a change directory
just above the directory which I want to tar and then using the UNIX tar
command from within the script.  Is this the best approach?

Thanks!
Hans



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to