I am sure just fumble fingered something here.... I am trying to port a Unix based 
script for use on our NT machine. The script is rather hard to read and for that I 
apologize.

Error: The process cannot access the file because it is being used by another process.

=== Script ====
#!/usr/bin/perl
###########################################################################
#
#  Copyright  (C) 1998 by Syncsort, Inc.
#  All Rights Reserved.
#  Revision 1.0  Original version RAM
#           1.1  Added volser and partition number RAM
#           1.2 Ported to NT by Mike Singleton
#
###########################################################################
# <title>: syncrpt..pl
#
# <usage>: 
#
my $HELP="
<description>:

This script must be run on the Backup Express master server.
This script must be run from the bin subdirectory of 
        Backup Express if the environment variable SSPRODIR is not set to the 
        Backup Express directory.
You must have root priviliges to run this script.

\"jobrpt\" will generate a report of completed and failed Backup Express
jobs, based on the information in the logs subdirectory.  Note that this
is not identical to the information contained in the Backup Express catalog.
In particular, it only provides information on the last 30 days worth of
jobs.

<options>:

-h                 : Help.

USAGE; \"$0 \"

Type \"$0 -h\" for help
";
# <dependencies>:
# None.
#
# <outputs>:
# This script uses a temporary file jobrpt.tmp 
# The report is written to standard output

###########################################################################
#       Initialization
###########################################################################
# load modules
use strict;
use English;
use Getopt::Std;
use Cwd;
# Set defaults

my $CUR_DIR=cwd;

my $RPTFILE="jobrpt.tmp";


###########################################################################
#       Parse arguments
###########################################################################
getopts('hn:p:o:s:') or die "$HELP";
($Getopt::Std::opt_h) and die $HELP;

# Get a temporary file id
my $COUNT=0;
my $OUT_TEMP="jobrpt.$COUNT";
my ($njob, @line, $current);
my (@jobid, %starttime, %jobname, %jobtype, %status, %endtime, %volser);
my $grepexpr;

format = 
@<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<< 
@<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$jobname{$_}, $jobtype{$_}, $starttime{$_}, $endtime{$_}, $volser{$_}
.

#grep all the job logs for the following codes:
#  Job start
my $JOBSTART  = 'SNBJH_3203J';
#  Condense start  
my $CONDSTART =  'SNBJH_3403';
#  Job end
my $JOBEND  = 'SNBJH_3211J';
#  Condense end
my $CONDEND =  'SNBJH_3401J';
#  Job cancelled
my $JOBCANC =  'SNBJH_3258J';
#  Job fail
my $JOBFAIL = '-1';
#  Volsers used
my $VOLUSED =  'SNBJH_3320J';
my %statcode =
    ( "$JOBEND" => '0',
      "$CONDEND" => '0',
      "$JOBFAIL" => '-1',
      "$JOBCANC" => '-2',
     );
my $MAXVLENGTH = 30;
my $search;

while (-f $OUT_TEMP) {
        $COUNT += 1;
        $OUT_TEMP="jobrpt.$COUNT";
}

# Open the temp file for write
# Check to make sure that job exists

open (OUTF,">$OUT_TEMP") || die "Cannot open output file $!";
my @files = glob('3*.log');
$grepexpr = "egrep \"$JOBSTART\|$CONDSTART\|$JOBEND\|$CONDEND\|$JOBCANC\|$VOLUSED\" 
@files>$OUT_TEMP";
system "$grepexpr";
close OUTF;


$njob = 0;
# Open the temp file for read
open (OUTF,"$OUT_TEMP") || die "Cannot open file for read, $!";
while (<OUTF>) {
    @line = split(' ');
# First the grep for the start of the job
#    print "Seventh token is $line[7]\n";
    $search = '$line[7] =~ /' . "$JOBSTART" . '/';
    if (eval $search) {
        chop $line[14]; # Remove the ")"
        $current = $line[14];
        $jobid[$njob++] = $current;
        $starttime{$current} = $line[2] . " ";
        $starttime{$current} .= $line[3] . " ";
        $starttime{$current} .= $line[4] . " ";
        $starttime{$current} .= $line[5] . " ";
        $starttime{$current} .= $line[6];
        $jobname{$current} = $line[11];
        $jobtype{$current} = $line[17];
        chop $jobtype{$current};
        $status{$current} = $statcode{$JOBFAIL};  #  Default
        $endtime{$current} .= $starttime{$current}; # Default
        $volser{$current} = '';
    }
    $search = '$line[7] =~ /' . "$CONDSTART" . '/';
    if (eval $search) {
        chop $line[15]; # Remove the ")"
        $current = $line[15];
        $jobid[$njob++] = $current;
        $starttime{$current} = $line[2] . " ";
        $starttime{$current} .= $line[3] . " ";
        $starttime{$current} .= $line[4] . " ";
        $starttime{$current} .= $line[5] . " ";
        $starttime{$current} .= $line[6];
        $jobname{$current} = $line[10];
        $jobtype{$current} = $line[10];
        $status{$current} = $statcode{$JOBFAIL};  #  Default
        $endtime{$current} .= $starttime{$current}; # Default
        $volser{$current} = '';  #  No volsers for Condense
    }
    $search = '$line[7] =~ /' . "$JOBEND" . '/';
    if (eval $search) {
#  First check whether the bytecount is nonzero
        if ($line[17] ne '0') {
            $status{$current} = $statcode{$JOBEND};
        } else {
            $status{$current} = $statcode{$JOBFAIL};
        };
        $endtime{$current} = $line[2] . " ";
        $endtime{$current} .= $line[3] . " ";
        $endtime{$current} .= $line[4] . " ";
        $endtime{$current} .= $line[5] . " ";
        $endtime{$current} .= $line[6];
    }
    $search = '$line[7] =~ /' . "$CONDEND" . '/';
    if (eval $search) {
        $status{$current} = $statcode{$CONDEND};
    }
    $search = '$line[7] =~ /' . "$JOBCANC" . '/';
    if (eval $search) {
        $status{$current} = $statcode{$JOBCANC};
    }
    $search = '$line[7] =~ /' . "$VOLUSED" . '/';
    if (eval $search) {
#        print "Line contains token 7 $line[7].\n";
        $search = '$volser{$current} =~ /' . "$line[9]" . '/';
        if (!(eval $search)) {
            $volser{$current} .= ' ' . $line[9] . '(' . $line[11] . ')';
        }
    }
};

# Now print out the hashed data
print "   *   *   *   *   *   ";
print "Completed jobs";
print "   *   *   *   *   *   \n";

print "Jobname             Type            Start                      End              
      Volsers(Partitions)\n";
foreach (@jobid) {
    if ($status{$_} eq $statcode{$JOBEND}) {
        if (length $volser{$_} > $MAXVLENGTH) {
            $volser{$_} = 'See job log';
        }
        write;
};
}
print "\n\n   *   *   *   *   *   ";
print "Cancelled jobs";
print "   *   *   *   *   *   \n";

print "Jobname             Type            Start                      End\n";
foreach (@jobid) {
    if ($status{$_} eq $statcode{$JOBCANC}) {
write;
};
}
print "\n\n   *   *   *   *   *   ";
print "Failed jobs";
print "   *   *   *   *   *   \n";

print "Jobname             Type            Start                      End\n";
foreach (@jobid) {
    if ($status{$_} eq $statcode{$JOBFAIL}) {
write;
};
}
exit 0; 
=== End Script====

DaVita Inc.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to