Ok, here is the entire script:
#!/usr/bin/perl -w
print "Post Production Report program \n";
print "Enter the Date (yyyymmdd) for the report: \n";
$date= <STDIN>;
chomp ($date);
print "Enter report type (d for detail or s for summary): \n";
$type= <STDIN>;
chomp ($type);
if ($type =~ /^d\b/) {
$reptr=-detail
} else {
$reptr=-summary
}
$1=~[\d0-9];
$2=~[\d0-9];
$3=~[\d0-9];
$4=~[\d0-9];
system `cd /tivoli/maestro/schedlog`;
$sched_log="M$date$1$2$3$4";
`conman "reptr $reptr $sched_log"`;
Basically the script is prompting you for a date of a report you want. The problem is is that the report name is always Myyyymmdd#### (# meaning any number) I need the code to be able take the date the user puts in and match that up with the file it finds and add the last 4 digits that are in the file name
Thanks in advance for any help
Bob
| [reply] [d/l] |
ddrumguy,
Okay. So you have a bunch of files in /tivoli/maestro/schedlog
and you know the file begins with M$date but you don't know
what the last 4 digits are? Correct? Will there only be one
file that begins M$date or will there be multiples? Do you
run the conman proc against only one at a time or can it
accept many?
I'd drop the $1, $2, $3, $4 stuff all together (I don't
think its doing anything for you since $_ is not defined
anywere - you should get warnings from these lines).
What you want is opendir, grep, readdir and closedir.
#!/usr/bin/perl -w
use strict;
print "Post Production Report program \n";
print "Enter the Date (yyyymmdd) for the report: \n";
chomp( my $date= <STDIN> );
print "Enter report type (d for detail or s for summary): \n";
chomp( my $type= <STDIN> );
my $reptr = substr( $type, 0, 1 ) eq "d" ? "-detail" : "-summary";
chdir( "tivoli" ) or
die "cannot cd to directory";
opendir(DIR, ".") or
die "cannot open directory: $!\n";
my @files = grep { /M$date/ } readdir(DIR);
closedir DIR;
foreach( @files ) {
print "Would run: conman reptr $reptr $_\n";
}
-derby | [reply] [d/l] |
basically the files in the schedlog directory are nothing more than log files that the reptr is going to run against. I just want the user to be able to slam in a date and let the code figure out the rest. Typically there are alot (hundreds) of these files in the directory. it would probably be ran against only one of them on any given day.
bob
| [reply] |