I'm having trouble with a little backup job I wrote. I'm using Win 2000 and
Perl 5.6.1. This backup job gathers a few files into one location, then
zips them up, then deletes the original files. I use the system command for
the zipping, because I use an external application (pkzip) for that. The
problem is that it zips up files from the wrong folder, specifically, the
folder where the perl job is running from (c:\perl). But when I take out
the zip part of the code and run it alone, it zips from the correct
directory. I tried to put a chdir right before the zip (in the 1st
program), but I must have done it wrong, because it had no impact. Can
someone tell me why the zipping is happening in a different directory than I
specified?
Here is the code from the 2 different programs:
<START of 1st program>
use warnings;
use strict;
use File::Copy;
###get the date
my ( $day, $month, $year ) = (localtime)[3..5];
$year += 1900;
$month = sprintf("%02d", $month+1);
$day = sprintf("%02d", $day);
###populate @mths array
my @mths = qw(00NUL 01Jan 02Feb 03Mar 04Apr 05May 06Jun 07Jul 08Aug 09Sep
10oct 11Nov 12Dec);
###copy PSR file to production
if (-e
"e:\\reports\\acs\\REJECTSacs_rejected_mail-$month$day$year.psr") {
copy ("e:\\reports\\acs\\REJECTSacs_rejected_mail-$month$day$year.psr",
"c:\\prod\\acs\\output\\REJECTSacs_rejected_mail-$year$month$day.psr")
or die "can't copy/rename PSR file: $!";
}
###copy emailrej file to production
if (-e "c:\\prod\\acs\\input\\emailrej.txt") {
copy ("c:\\prod\\acs\\input\\emailrej.txt",
"c:\\prod\\acs\\output\\emailrej_$year$month$day.txt")
or die "can't copy emailrej file: $!";
}
###rename email.dat file
rename("c:\\prod\\acs\\output\\email.dat",
"c:\\prod\\acs\\output\\email_$year$month$day.dat")
or die "can't rename email.dat file: $!";
###create zip file
system("pkzipc -add e:\\tepcbkup\\acsage\\acsage_$year$month$day.zip
c:\\prod\\acs\\output\\*.*");
###move zip file to month folder
if (!-e
"e:\\tepcbkup\\acsage\\$mths[$month]\\acsage_$year$month$day.zip") {
move ("e:\\tepcbkup\\acsage\\acsage_$year$month$day.zip",
"e:\\tepcbkup\\acsage\\$mths[$month]\\acsage_$year$month$day.zip")
or die "can't move zip file to month folder: $!";
}
###delete files from production
unlink "c:\\prod\\acs\\output\\emailrej_$year$month$day.txt" or warn "can't
delete emailrej file: $!";
unlink "c:\\prod\\acs\\output\\REJECTSacs_rejected_mail-$year$month$day.psr"
or warn "can't delete PSR file: $!";
unlink "c:\\prod\\acs\\output\\email_$year$month$day.dat" or warn "can't
delete email.dat file: $!";
<END of 1st program>
<START of 2nd program, which works>
use warnings;
use strict;
#use File::Copy;
###get the date
my ( $day, $month, $year ) = (localtime)[3..5];
$year += 1900;
$month = sprintf("%02d", $month+1);
$day = sprintf("%02d", $day);
###create zip file
system("pkzipc -add e:\\tepcbkup\\acsage\\acsage_$year$month$day.zip
c:\\prod\\acs\\output\\*.*");
<END of 2nd program>
So to restate, or elaborate, the 1st program works fine except the
system(pkzipc) zips up files from the wrong directory. I don't get any
errors on the screen. In the 2nd program, the system(pkzipc) zips up the
right files. Thanks for any help.
Rebecca
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]