in reply to Failboat -- An Emotionally Disturbed Tool For Checking NetBackup Client Coverage

Thanks for contributing. I mean that earnestly.

Please forgive my one small Unix gripe, however. There is no need to pipe grep output to awk. awk will do it all.

me@mybox:~/sandbox $ cat data.txt bob 21 xyz sam 8 uuu bob 90 fff sue 12 qaz bob 99 har me@mybox:~/sandbox $ grep bob data.txt | head -1 | awk '{print $2}' 21 me@mybox:~/sandbox $ awk '/bob/ {print $2; exit}' data.txt 21

I was referring to this line of yours:

$lastValidBackupTime=`/usr/openv/netbackup/bin/admincmd/bpcatlist -cli +ent $client 2>&1 | grep $client | head -n1 | awk '{print $2}'`;

Replies are listed 'Best First'.
Re^2: Failboat -- An Emotionally Disturbed Tool For Checking NetBackup Client Coverage
by jwkrahn (Abbot) on Mar 19, 2010 at 15:28 UTC

    That is your problem with it, Really?

    How about using Perl to do that, since we are doing this in a Perl program:

    open my $PIPE, '-|', "/usr/openv/netbackup/bin/admincmd/bpcatlist -cli +ent $client 2>&1" or die "Cannot open pipe from 'bpcatlist' $!"; while ( <$PIPE> ) { next unless /$client/; $lastValidBackupTime = ( split )[ 1 ]; last; } close $PIPE or warn $! ? "Error closing 'bpcatlist' pipe: $!" : "Exit status $? from 'bpcatlist'";

      jwkrahn wrote:

      >That is your problem with it, Really?

      Yes. I did not go through the trouble to respond for the sake of sarcasm. It was a sincere response.

      Besides, I suspected someone more clever and skilled at Perl such as you would respond with appropriate Perl syntax, and I was still able to spread the message of usless use of grep.

      So it looks like a win-win situation to me.

        (Sorry, been posting Anonymously..deh)

        I could have done it in straight Perl, but it's kind of clumsy and elaborate by comparrison, considering i'm not really doing anything but invoking an external command.
Re^2: Failboat -- An Emotionally Disturbed Tool For Checking NetBackup Client Coverage
by Anonymous Monk on Mar 19, 2010 at 18:16 UTC
    Oh, I know. That backticked statement was just off the top of my head. I'm aware that awk is perfectly capable of doing what i've described ala piping. Sadly, i've never used awk enough to know how to use it properly in this context.