Rolf:
I'm not a Perl guy, but I can tell you that the bpmedialist output you
showed below is missing another line. The 2/3 date is the date the tape was
allocated in the mediaDB, the date BELOW, *which isn't shown*, is the
expiration date.
What I do in my scripts ( not a perl thing, but maybe it will put you on the
right track) is pipe that command to tail +6, that will remove the header
information and leave you with just the data.
Your better bet would be to do a bpmedialist -l for a raw long listing and
get the date that way. I have included an old email to change the utime to
a julian style date in perl or use /usr/openv/netbackup/bin/bpdbm -ctime
$utime and get it from that output. But in any case, I think it would be
much faster. The fields are as follows:
media id
partner id
version
density
time allocated
time last written
time of expiration
time last read
Kbytes
nimages
vimages (unexpired images)
retention level
volume pool
number of restores
status >= 0x200 Multiplexing is TRUE.
>= 0x080 Imported is TRUE.
>= 0x040 Multiple retention levels is TRUE.
>= 0x008 The status is Full.
>= 0x004 This is an unreported state.
>= 0x002 The status is Suspended.
== 0x001 The status is Frozen.
== 0x000 The status is Active.
hsize
ssize
l_offset
reserved
psize
reserved
4 reserved fields
That should make it easier on you and you wouldn't have to worry about the
formatting.
I hope that helps.
David
+++++++++++++++++++++++++BEGIN EMAIL
SNIPPET++++++++++++++++++++++++++++++++++
-----Original Message-----
From: veritas-bu-admin AT Eng.Auburn DOT EDU
[mailto:veritas-bu-admin AT Eng.Auburn DOT EDU]On Behalf Of Ron Jack
(Programming)
Sent: Friday, March 09, 2001 8:52 AM
To: Zufall, Ken; veritas-bu AT mailman.eng.auburn DOT edu
Subject: Re: [Veritas-bu] converting unix time
I'm lazy when it comes to date conversion; I let Perl's Date::Manip and
Date::Calc handle it.
#!/usr/local/bin/perl -w
use strict;
use Date::Manip qw(ParseDate UnixDate);
use Date::Calc qw(:all);
my $string_date = "today";
my $date = ParseDate($string_date);
if(!$date) {
warn "Bad date string: $_\n";
}
else {
my $unixdate = UnixDate($date,"%s");
print "The current epoch time is $unixdate\n";
my ($year,$month,$day) = UnixDate($date,"%Y","%m","%d");
print "Today's date is $month/$day/$year\n";
my ($y,$m,$d) = Nth_Weekday_of_Month_Year($year,$month,7,1);
print "The first Sunday of this month was on $m/$d/$y\n";
}
Yep, you have to go get the modules.
http://search.cpan.org/search?dist=DateManip
http://search.cpan.org/search?dist=Date-Calc
+++++++++++++++++++++++++END EMAIL SNIPPET++++++++++++++++++++++++++++++++++
<><><><><><><><><><><><><><><><><><><><>
David A. Chapa
NetBackup Consultant
DataStaff, Inc.
http://www.consulting.datastaff.com
847 413 1144
---------------------------------------
NBU-LSERV AT datastaff DOT com - Adv. Scripting
http://www.xbpadm-commands.com
-----Original Message-----
From: veritas-bu-admin AT mailman.eng.auburn DOT edu
[mailto:veritas-bu-admin AT mailman.eng.auburn DOT edu]On Behalf Of Rolf
Sent: Saturday, March 02, 2002 3:08 PM
To: Veritas-bu AT mailman.eng.auburn DOT edu
Subject: [Veritas-bu] NB Perl scripting
Hi there all,
I am quite new in doing scripts with Perl, so i would like your help.
For example i want to extract information from the bpmedialist command to
get the label ID's and the expiration date.
When i execute the bpmedialist -mlist command i get the following.
Server Host = thunderbird
id rl images allocated last updated density kbytes
restores
vimages expiration last read <-------
STATUS ------->
----------------------------------------------------------------------------
----
MEDIA 1 16 02/03/2002 19:38 02/25/2002 08:49 4mm 16365
0
Out of this information i thus want the "MEDIA" and the "02/03/2002"
information.
I create the following script
-----------------------------
open (bpmedialist, "c:/veritas/netbackup/bin/admincmd/bpmedialist -mlist|")
|| die "cannot open file $!/n" ;
$result = <bpmedialist>;
@line = split(/\s+/, $result);
print @line[0];
-----------------------------
Now my problem is that this script only reads the first line of the output
of the bpmedialist command, thus:
Server Host = thunderbird
So when executing the command print @line[0]; i get the result "Server", and
with print @line[3]; i get the result "thunderbird".
What should i change to read the whole file into the @line and calculate
wich fields i needs? (so i can use for example print @line[30] to extract
the MEDIA)
Hope anybody can help me with this.
Thanks!
Rolf
|