Home > Archive > PERL Miscellaneous > May 2005 > backticks and Veritas Netbackup commands
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
backticks and Veritas Netbackup commands
|
|
| Brian W 2005-05-29, 8:56 pm |
| 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?
| |
| Brian McCauley 2005-05-29, 8:56 pm |
| Brian W wrote:
> 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.
|
|
|
|
|