in reply to Parse backup log

In addition to matija's suggestion, you appear to need to also take into account lines which do not contain the expires, date, and time fields. In those cases, even with matija's example, your status variable would be undefined (or blank.)

Replies are listed 'Best First'.
Re: ^2 Parse backup log
by mrbbq (Sexton) on Apr 20, 2004 at 19:44 UTC
    even after the changes I am still not getting any matches on frozen? My code as it stands now is like this:
    sub match { while (<IMAGES>) { if ($_ =~ /^(\s+)MVA/o) { $_ =~ s/(\s+)//o; chop; #my ($tape_id, $expiration, $date, $time, $sta +tus) = split (/ /); my ($blank, $tape_id, $expiration, $date, $tim +e, $status)=split(/\s+/); #create_entry($tape_id, $expiration, $date, $t +ime, $status) create_entry($blank, $tape_id, $expiration, $d +ate, $time, $status) if ($status eq "(FROZEN)"); #if ($status eq /FROZEN/); } } }
    and i still get no matches in the html form?

    Edited by theorbtwo to add code tags, and remove br tags.

      Wait a second. Where did the

      if ($_ =~ /^(\s+)MVA/o) {
      come from? None of your IMAGE lines begin with MVA (with or without spaces.) Your match routine looks for lines beginning with MVA before trying to do the create_entry() function. Given the input you've supplied, it will never match any lines.

      I'm pretty confused at this point.

        Sorry I only gave a snipet of the output of the command that runs at the begining of the script.....the command also spits out some stuff that I do not want matched. Check it out:
        bash-2.03$ /usr/openv/netbackup/bin/admincmd/bpmedialist -summary | mo +re ********************************************************************** +********* MEDIA SUMMARY FOR SERVER sjzbkp004 ON Tue Apr 20 13:07:59 2004 ********************************************************************** +********* ACTIVE FULL SUSPENDED FROZEN IMPORTED 159 1782 0 14 0 Number of NON-ACTIVE media that: 8 - are non-active and not written yet ST0315 (FROZEN) ST0306 (FROZEN) ST0304 (FROZEN) ST0314 (FROZEN) ST0308 (FROZEN) ST0309 (FROZEN) ST0312 (FROZEN) ST4910 (FROZEN) 93 - will expire within 1 week ST2885 expires 04/20/2004 23:31 ST6200 expires 04/20/2004 23:37 ST6221 expires 04/21/2004 23:53 ST2819 expires 04/21/2004 00:01 ST2485 expires 04/20/2004 23:44 ST6216 expires 04/21/2004 00:01
        So there are a few lines I never want matched. Sorry for the confusion.