Like in the shell, say it as "M${date}${num}". You can give $num the form you want with sprintf. Or just use sprintf for the whole thing.
After Compline, Zaxo
| [reply] |
You could give us a little more info (code) 'cuz you don't
say how you're getting the number. For simplicity sake,
let's say your using a loop counter - then just use
sprintf like so:
$sched_log = sprintf( "%c%s\\%04d", "M", $date, $loop_counter);
-derby | [reply] [d/l] |
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] |