Hello all --

The script I'm working on is here:

#!/usr/bin/perl
# A script to back up all of the important information on <servername>.
# Written by: Charlotte M. Oliver
# Written on: 11/13/02
      
use strict;             # Be pedantic.

my ($safe, $getDirs, $backThatThangUp, @directories, $copy);

$safe = '/mnt/hd/backups/';   # Where do we want to back up to?
Consistency!
&getDirs;
&backThatThangUp;

sub getDirs {         # A subroutine that parses the directories in
backUpDirs and reads them into an array.
        @directories = `cat ./backUpDirs`
             or die "Can't Open Back-up Directory File: $!";
   }

sub backThatThangUp { # The subroutine that actually backs up the
directories to $safe.
     foreach (@directories) {
     $copy = `cp -Rp $_ $safe`;
     print $copy;
     }
 }

I've gotten &getDirs working properly, but I am having some problems
with &backThatThangUp.
There may be a better way to do this within Perl, but I'm not aware of
it. :)

When I run this script, I get this:

cmoliver@<server>:~/scripts/backup$ perl backup.pl
cp: missing destination file
Try `cp --help' for more information.
sh: /mnt/hd/backups/: is a directory
cp: missing destination file
Try `cp --help' for more information.
sh: /mnt/hd/backups/: is a directory

(repeated a few more times -- once for each element in the array)

However, I can run the identical command on the command line and the
shell copies the files over to $safe.

I have also tried using File::Copy, but found that it doesn't copy over
directories and doesn't seem to handle arrays very well.  It's quite
possible that I was using it incorrectly, though.  I just began with
Perl a week or two ago -- can someone help point me in the right
direction?

---
Charlotte Oliver
Junior Systems Engineer 
Case Design/Remodeling, Inc.

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

Reply via email to