Mike Singleton wrote:
>
> This script will ultimately return the values of the regex strings for
> successful backup. I am stumped right now as how to proceed, as the script
> seems to run without error, yet return nothing.
>
> ====== Log File =====
> 172.16.54.132 ssjobhnd Thu Jun 27 02:00:01 2002 SNBJH_3075J Syncsort Backup
> Express version 2.1.3; Copyright Syncsort Incorporated, 1996-2001
[snip]
> 172.16.54.132 ssjobhnd Thu Jun 27 03:42:17 2002 SNBJH_3499I Job complete:
> job 1025168400 status 0
> ==== End Log File====
You should probably read the perl style guide - the indentation is
inconsistant and the use of all upper case for variable names is frowned
upon.
> # ======================================================================
> #
> # Perl Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
> #
> # NAME: jobreport
> #
> # AUTHOR: Mike Singleton , Davita Inc
> # DATE : 7/3/2002
> #
> # PURPOSE: SyncSort Reporting
> #
> # ======================================================================
> ###########################################################################
> #
> #
> my $HELP="
You could use a different quoting style do that you don't have to
backslash all the double quotes in the text.
perldoc perlop
> <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 admin 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 $SSPRODIR/bin/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 $SSPRODIR=$ENV{SSPRODIR};
>
> # Check for $SSPRODIR.
> #if ("$SSPRODIR" eq "") {
^ ^
You shouldn't put quotes around single variables.
perldoc -q quoting
Found in /usr/lib/perl5/5.6.0/pod/perlfaq4.pod
What's wrong with always quoting "$vars"?
> # if (! -x "$CUR_DIR\/ssbrowse") {
^^
Slashes don't have to be escaped unless your quote delimiters are also
slashes.
> # die "$0: ERRPR: You must either set SSPRODIR or run this script from
> Backup Express bin directory.\n\n$HELP";
> # }
> # chdir '..';
> # $SSPRODIR=cwd;
> # chdir $CUR_DIR;
> #}
>
> #my $RPTFILE="$SSPRODIR/bin/jobrpt.tmp";
> my $RPTFILE="jobrpt.tmp";
>
> ###########################################################################
> # Parse arguments
> ###########################################################################
> getopts('hn:p:o:s:') or die "$HELP";
^ ^ unnesessary
> #($Getopt::Std::opt_h) and die $HELP;
>
> my $JOB_NAME="";
> if (@ARGV) {
> $JOB_NAME=shift @ARGV;
> }
> (@ARGV==0) or die "$0: ERROR: Too many arguments on the command line.";
>
> # Get a temporary file id
> my $COUNT=0;
> #my $OUT_TEMP="$SSPRODIR/jobrpt.$COUNT";
> my $OUT_TEMP="jobrpt.$COUNT";
> my ($njob, @line, $current);
> my (@jobid, %starttime, %jobname, %jobtype, %status, %endtime, %xfer,
> %xfer1,%xferfiles,%volser, );
> my $grepexpr;
>
> format =
> @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<
> @<<<<<<<<<<<<<<<<<<<<<<<<<
> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<
> $jobname{$_}, $jobtype{$_}, $starttime{$_}, $endtime{$_},
> $xfer{$_},$xfer1{$_}, $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';
> # Transfer stats
> my $XFER1 = 'SNBJH_3710J';
> my $XFER = 'SNBJH_3308J';
> # Xfer File stats
> my $XFERFILES = 'SNBJH_3304J';
> my %statcode =
> ( "$JOBEND" => '0',
^ ^
> "$CONDEND" => '0',
^ ^
> "$JOBFAIL" => '-1',
^ ^
> "$JOBCANC" => '-2',
^ ^
Quoting these variables is so redundant and unnecessary.
> );
> my $MAXVLENGTH = 60;
> my $search;
>
> while (-f $OUT_TEMP) {
> $COUNT += 1;
> #$OUT_TEMP="$SSPRODIR/jobrpt.$COUNT";
> $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 $!";
^^^^
Here you open the file handle OUTF to write to the file $OUT_TEMP.
> #$grepexpr = "egrep
> \"$JOBSTART\|$CONDSTART\|$JOBEND\|$CONDEND\|$JOBCANC\|$VOLUSED\" \` ls -tr
^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^
The vertial bar does not have to be escaped in double quoted strings.
You can avoid all the back-slashing by using a different quoting
operator like qq().
> ../logs/3*.log\` >$OUT_TEMP";
> #system "$grepexpr";
^ ^ unnecessary.
> #my $files = `ls -t 3*.log`;
> #print $files;
> #$grepexpr = "grep32
> \"$JOBSTART\|$CONDSTART\|$JOBEND\|$CONDEND\|$JOBCANC\|$VOLUSED\"
> $files>$OUT_TEMP";
> #system "$grepexpr";
^ ^ unnecessary.
> #print $OUT_TEMP;
> my @files = glob('3*.log');
> $grepexpr = "egrep
> \"$JOBSTART\|$CONDSTART\|$JOBEND\|$CONDEND\|$JOBCANC\|$XFER\|$XFER1\|$XFERFI
> LES\|$VOLUSED\" @files>$OUT_TEMP";
> system "$grepexpr";
^ ^ unnecessary.
> print $OUT_TEMP;
> close OUTF;
^^^^
Here you close the file handle OUTF but you haven't written anything to
the file. Perhaps you want:
print OUTF $OUT_TEMP;
close OUTF;
> $njob = 0;
> # Open the temp file for read
> open (OUTF,"$OUT_TEMP") || die "Cannot open file for read, $!";
^ ^ unnecessary.
> while (<OUTF>) {
> @line = split(' ');
> # First the grep for the start of the job
> print "Seventh token is $line[7]\n";
> $search = '$line[7] =~ /' . "$JOBSTART" . '/';
^ ^ unnecessary.
> if (eval $search) {
Is there any reason that you are using eval instead of just using the
regular expression here? Perhaps you should be using the qr// operator
for these variables like $JOBSTART.
> chop $line[14]; # Remove the ")"
^^^^^^^^^^^^^^
How do you know it is removing a ")"?
chop $line[14] if substr( $line[14], -1 ) eq ')';
Or:
$line[14] =~ s/\)$//;
> $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];
$starttime{$current} = join ' ', @line[2 .. 6];
> $jobname{$current} = $line[11];
> $jobtype{$current} = $line[17];
> chop $jobtype{$current};
What character are you removing here?
> $status{$current} = $statcode{$JOBFAIL}; # Default
> $endtime{$current} .= $starttime{$current}; # Default
> $volser{$current} = '';
> }
[snip]
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]