I have a program which returns backup data. It currently uses only one function of a module an I would like to modify it to use others.
68 212844
69 HASH(0x7eff68)
'class' => 'NT-Development'
'classtype' => 13
'client' => 'ahrdev'
'compression' => 0
'elapsed' => 0000037093
'ended' => 1022923736
'filelistcount' => 1
'files' => 'ALL_LOCAL_DRIVES'
'fileslastwritten' => 0
'group' => ''
'jobid' => 212844
'jobpid' => 17667
'jobtype' => 'immediate'
'kbytes' => 295857
%images and %jobs are populated like this:
my %images = bpimagelist('$record->{client}');
my %jobs = bpdbjobs();
Subroutine which produces desired output:
sub post2Web {
my $jRef = shift();
my $infoformat = "%-30s %-40s\n";
### Base directory of Web database
my $base = '/usr/openv/netbackup/jobs/db';
### Job ID index directory
my $jidbase = '/usr/openv/netbackup/jobs/byJobID';
### make today's client directory if ! exist
my $bkup_date = strftime "%Y%m%d", localtime($jRef->{started});
my $wkdir = "$bkup_date/TEST/$jRef->{client}";
mkpath("$base/$wkdir", 0, 0755) unless -d "$base/$wkdir";
### make directory to hold class/schedule/jobid info
my $csdir = "$jRef->{class}/$jRef->{schedule}/$jRef->{jobid}";
mkpath("$base/$wkdir/$csdir", 0, 0755) unless -d "$base/$wkdir/$csdir"
+;
symlink "../db/$wkdir/$csdir", "$jidbase/$jRef->{jobid}"|| die "$!";
open(INFO, ">$base/$wkdir/$csdir/info") || die "Unable to open/write
+ $base/$wkdir/csdir/info, $!";
printf INFO $infoformat, "jobid", $jRef->{jobid};
printf INFO $infoformat, "jobtype", $jRef->{jobtype};
printf INFO $infoformat, "state", $jRef->{state};
printf INFO $infoformat, "status", $jRef->{status};
printf INFO $infoformat, "client", $jRef->{client};
printf INFO $infoformat, "server", $jRef->{server};
printf INFO $infoformat, "stunit", $jRef->{stunit};
printf INFO $infoformat, "started", $jRef->{started};
printf INFO $infoformat, "elapsed", $jRef->{elapsed};
printf INFO $infoformat, "ended", $jRef->{ended};
printf INFO $infoformat, "files", $jRef->{files};
printf INFO $infoformat, "Mbytes", $jRef->{Kbytes};
printf INFO $infoformat, "kbytes last written",
close INFO;
}
</CODE<p>
What I want to do is incorporate pertinent values from <CODE> %image
in the output.
This separate piece of code will give me the desired output, but I just don't know how to combine the two.
#!/usr/local/bin/perl -w
use strict;
use NBUX;
my $record;
my %images = bpimagelist('$record->{client}');
foreach my $key (sort keys %images) {
prtID($images{$key});
}
sub prtID {
my $ref = shift;
print "client = $ref->{client}\n";
print "\tid= $ref->{id}\n";
}
Sorry if this is a little verbose; please feel free to say so.
Edit kudra,
2002-06-06
Added readmore