Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Parsing A Report

    I have a system report that some of you may be familiar with. It is
    the output from the print_manifest command on an HP-UX system with
    ignite installed. There are divisions in the text file that I am
    trying to break up, but feel like I am going about wrong. I am trying
    to extract the block of text within 'Installed Software' up to the
    next major heading. Can someone check my work and comment? Thanks. See
    below:

    Report:

    Installed Software

    Your system was installed with HP-UX version B.11.11.

    Your system has the following software products installed and
    configured on the system disk drive(s).

    Product Revision Description
    B2491BA B.11.11 MirrorDisk/UX
    B3701AA C.03.25.00 HP GlancePlus/UX Pak for s800
    11i
    B3913DB C.03.30.01 HP aC++ Compiler (S800)
    B5725AA B.3.3.116 HP-UX Installation Utilities
    (Ignite-UX)
    B6834AA B.01.00 HP-UX Security Patch Check Tool
    B9901AA A.03.05 HP IPFilter 3.5alpha5
    BUNDLE11i B.11.11.0102.2 Required Patch Bundle for HP-UX
    11i, February 2001
    CDE-English B.11.11 English CDE Environment
    FDDI-00 B.11.11.01 PCI FDDI;Supptd
    HW=A3739A/A3739B;SW=J3626AA
    FibrChanl-00 B.11.11.06 PCI/HSC FibreChannel;Supptd
    HW=A6684A,A6685A,A5158A
    GigEther-00 B.11.11.14 PCI/HSC GigEther;Supptd
    HW=A4926A/A4929A/A4924A/A4925A;SW=J1642AA
    HPUX11i-OE B.11.11.0106 HP-UX 11i Operating Environment
    Component
    HPUXBase64 B.11.11 HP-UX 64-bit Base OS
    HPUXBaseAux B.11.11.0106 HP-UX Base OS Auxiliary
    HWEnable11i B.11.11.0106.8 Hardware Enablement Patches for
    HP-UX 11i, June 2001
    Ignite-UX-11-11 B.3.3.116 HP-UX Installation Utilities
    for Installing 11.11 Systems
    J4189-11001B E.10.18 Hewlett-Packard JetDirect
    Printer Installer for Unix
    OnlineDiag B.11.11.03.08 HPUX 11.11 Support Tools
    Bundle, Jun 2001
    RAID-00 B.11.11.01 PCI RAID; Supptd HW=A5856A


    LVM File System Configuration

    This system is configured with Logical Volume Manager (LVM) file
    systems.
    Refer to the File System layout section for information on the LVM
    layout.


    JFS File System Configuration

    This system is configured with a Journaled File System (referred
    to
    as either JFS or VXFS). Refer to the File System layout section
    for
    information on JFS/VXFS file systems.


    Code:

    #!/usr/contrib/bin/perl -w

    open SOFTWARE, "system.txt" or die "Cannot open file!";

    $flag = 0;
    while (<SOFTWARE>) {
    if (/^Installed Software/) {
    $flag = 1;
    next;
    }
    if ($flag) {
    last if (/^\w+/);
    # Where we do the work.
    }
    }
    raven Guest

  2. Similar Questions and Discussions

    1. preflight XML report differs from droplet report
      Hi all, When i create a xml-report 'by hand' with the preflight tool, it generates much more info then when i use the same preflight profile as a...
    2. Bug report in 7.4
      Is this known? If you create a table with a SERIAL and then rename the table you can't dump/restore the database. The create table creates a...
    3. PDF::Report
      Hi I've been using PDF::Report, which is a nice wrapper around PDF::API2. My problem is that it doesn't handle the special Danish characters æøå...
    4. How to link 3 different combo boxex in a form (as report criteria) to the report
      I would like to use 3 combo boxes in a form as parameter criteria for a report. When I open a report, there will be a pop up form with 3 combo...
    5. Report
      I have a form with a subform set up on a tab format. My main form is linked to a table with customer info (Name, address etc) The sub form is a...
  3. #2

    Default Re: Parsing A Report

    On Thu, 18 Sep 2003 09:43:02 -0700, raven wrote:
    > I have a system report that some of you may be familiar with. It is
    > the output from the print_manifest command on an HP-UX system with
    > ignite installed. There are divisions in the text file that I am
    > trying to break up, but feel like I am going about wrong. I am trying
    > to extract the block of text within 'Installed Software' up to the
    > next major heading. Can someone check my work and comment? Thanks. See
    > below:
    > [...]
    Actually, it's very easy. I won't provide you with any code for now, only
    the "way of thinking" (although I might be wrong).

    Start collecting data after you've recognized that 'Installed Software' is
    the beginning string on the line.

    Stop collecting data when you reach the next string that begins at the
    beginning of the line (hope you'll understand what I mean with that), as
    all the lines you want seem to be indented.

    However, I wouldn't have done it this way. :-) I would have looped
    through the lines and started collection data as soon as I reach something
    I can count as 3 columns (eventually, and in addition, after having met
    that 'Product', 'Revision', 'Description' line).

    Something like that (although I have no idea if it works);

    while ( <DATA> ) {
    chomp;
    my @cols = split( /\s+/ );
    if ( $cols[0] =~ m,\d+, ) {
    ## Yeah, I want those lines with numbers in the first column!
    print join( "\t", @cols );
    }
    }

    I don't know if this works; I'm watching soccer and have had a few beer,
    so... :-)
    > $flag = 0;
    One thing I've learnt during my "Perl period" is that you never should use
    any "flags" in your code. If you have to, you most probably do something
    wrong. Can't really explain it, though...


    --
    Tore Aursand <tore@aursand.no>

    "You know the world is going crazy when the best rapper is white, the best
    golfer is black, France is accusing US of arrogance and Germany doesn't
    want to go to war."
    Tore Aursand Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139