--=====================_78494899==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
Rolf:
You can do this quite easily with the NBUX tool kit.
#!/usr/bin/perl
use NBUX;
%media = bpmedialist();
foreach $id (keys %media) {
$media_id = $media{$id}->{"media_id"};
$allocated = $media{$id}->{"allocated"};
print "$media_id $allocated\n";
}
NBUX is available here:
http://sourceforge.net/projects/nbux
Regarding your Perl code below, you need to change a couple things:
1. To read the whole file into a list, use @LINES = <bpmedialist>
(assigning a filehandle to a scalar only reads the first line.)
2. Use a foreach loop or similar to iterate over each line in the list in turn.
You could also just use a while loop like this:
while( <bpmedialist> ) {
@line = split( /\s+/, $_ );
.....
....
}
Best regards,
--PLB
At 01:07 PM 03/02/2002 -0800, Rolf wrote:
>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
>
>
>
>
>
--=====================_78494899==_.ALT
Content-Type: text/html; charset="us-ascii"
<html>
<br>
Rolf:<br>
<br>
You can do this quite easily with the NBUX tool kit.<br>
<br>
#!/usr/bin/perl<br>
<br>
use NBUX;<br>
<br>
%media = bpmedialist();<br>
<br>
foreach $id (keys %media) {<br>
<br>
$media_id = $media{$id}->{"media_id"};<br>
$allocated = $media{$id}->{"allocated"};<br>
<br>
print "$media_id $allocated\n";<br>
<br>
}<br>
<br>
NBUX is available here:<br>
<br>
<a href="http://sourceforge.net/projects/nbux"
eudora="autourl">http://sourceforge.net/projects/nbux<br>
<br>
</a>Regarding your Perl code below, you need to change a couple
things:<br>
<br>
1. To read the whole file into a list, use @LINES = <bpmedialist>
(assigning a filehandle to a scalar only reads the first line.)<br>
2. Use a foreach loop or similar to iterate over each line in the list in
turn.<br>
<br>
You could also just use a while loop like this:<br>
<br>
while( <bpmedialist> ) {<br>
@line = split( /\s+/, $_ );<br>
.....<br>
....<br>
}<br>
<br>
Best regards,<br>
<br>
--PLB<br>
<br>
<br>
At 01:07 PM 03/02/2002 -0800, Rolf wrote:<br>
<blockquote type=cite class=cite cite><font face="arial" size=2>Hi there
all,</font><br>
<br>
<font face="arial" size=2>I am quite new in doing scripts with Perl, so i
would like your help.</font><br>
<br>
<font face="arial" size=2>For example i want to extract information from
the bpmedialist command to get the label ID's and the expiration
date.</font><br>
<font face="arial" size=2>When i execute the bpmedialist -mlist command i
get the following.</font><br>
<br>
<font face="arial" size=2>Server Host = thunderbird</font><br>
<br>
<font face="arial" size=2> id rl
images allocated
last updated density kbytes
restores<br>
vimages expiration last
read <------- STATUS
-------><br>
--------------------------------------------------------------------------------<br>
MEDIA 1 16
02/03/2002 19:38 02/25/2002 08:49
4mm 16365
0<br>
</font><br>
<br>
<font face="arial" size=2>Out of this information i thus want the
"MEDIA" and the "02/03/2002"
information.</font><br>
<br>
<font face="arial" size=2>I create the following script</font><br>
<br>
<font face="arial" size=2>-----------------------------</font><br>
<br>
<font face="arial" size=2>open (bpmedialist,
"c:/veritas/netbackup/bin/admincmd/bpmedialist -mlist|") || die
"cannot open file $!/n" ;</font><br>
<br>
<font face="arial" size=2>$result = <bpmedialist>;<br>
@line = split(/\s+/, $result);<br>
print @line[0];<br>
-----------------------------</font><br>
<br>
<font face="arial" size=2>Now my problem is that this script only reads
the first line of the output of the bpmedialist command,
thus:</font><br>
<font face="arial" size=2>Server Host = thunderbird</font><br>
<br>
<font face="arial" size=2>So when executing the command print @line[0]; i
get the result "Server", and with print @line[3]; i get the
result "thunderbird".</font><br>
<br>
<font face="arial" size=2>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)</font><br>
<br>
<font face="arial" size=2>Hope anybody can help me with
this.</font><br>
<br>
<font face="arial" size=2>Thanks!</font><br>
<br>
<font face="arial" size=2>Rolf</font><br>
<br>
<br>
<font face="arial" size=2> <br>
</font> <br>
</blockquote></html>
--=====================_78494899==_.ALT--
|