backticks and Veritas Netbackup commands

B

Brian W

I'm trying to write a very simple script to print the output of
bpplinfo <policyname> -L
for every Netbackup Policy at once. (I'll modify it to do more later.)

#!/usr/bin/perl -w
$BPPLLIST = "/opt/openv/netbackup/bin/admincmd/bppllist";
$TEMPPOLICYFILE = "/tmp/tmppol.out";

system "$BPPLLIST > $TEMPPOLICYFILE";
open ( POLFILE , $TEMPPOLICYFILE ) || die "couldnt open tmppol.out";
while ( <POLFILE> ) {
my $BPPLINFO = (`/opt/openv/netbackup/bin/admincmd/bpplinfo $_ -L `;
push@INFO,$BPPLINFO;
}
print @INFO;
`rm /tmp/tmppol.out`;

The problem is in the

$BPPLINFO = `/opt/openv/netbackup/bin/admincmd/bpplinfo $_ -L `

Whether I do this in the backticks, or in a roundabout fashion with the
system function, the command still fails because Veritas wrote its
utilities with the bizarre requirement to put the option flag AFTER the
arguement. When I run it I see the failed output just as if I had run
from the shell:

# bpplinfo POLICYNAME ; -L

I don't understand Perl super-well, but apparently the backticks and
system function both try to execute the -L separatelly from the
bpplinfo POLICYNAME.

Can anyone help me get around this?
 
B

Brian McCauley

Brian said:
while ( <POLFILE> ) {
my $BPPLINFO = (`/opt/openv/netbackup/bin/admincmd/bpplinfo $_ -L `;
When I run it I see the failed output just as if I had run
from the shell:

# bpplinfo POLICYNAME ; -L

Possilbly even more like

# bpplinfo POLICYNAME
# -L

i.e. with a newline between rather than semicolon.
I don't understand Perl super-well, but apparently the backticks and
system function both try to execute the -L separatelly from the
bpplinfo POLICYNAME.

Yes, that how shell treats newline characters.
Can anyone help me get around this?

Strip the newline character from the end of the string in $_.

This is what the Perl command chomp is for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top