Re: AW: Scripting: processing stanzas

From: Bruce Harvey (BruceH@ROUTESCAPE.COM)
Date: Wed Mar 19 2003 - 12:04:38 EST


I know exactly what Simon's talking about, I think.

For example, the info in /etc/passwd is in 'record' format, while
/etc/security/passwd is in "stanza" format. It'd be nice to have a routine
that could parse multi-line entries.

It's easy to parse one like the /etc/passwd file, where the fields are
separated by 'colons' (field1:field2:field3:...), but it's much more of a
pain when your record separator is a line of whitespace, not just a line
ending. Example:

Entry1
        name = fred
        address = 123 Anywhere Lane
        address1 = Bungalow A-2
        city = RightHere
        county = line
        province = rightbigone
        country = mine
        telephone = +012-34-5-67-89

Entry2
        name = irving
        address = (none)
        city = nowhere
        telephone = 0000000000

Entry 3
         ... and so on and so forth.

It would be very nice to have a utility that could:

        1. parse all of the stanzas to obtain all member values
        2. "flatten" the file into one line, if necessary
        3. retrieve a member value (or all) given an entry name
        4. Retrieve all entry name with a given member value
        5. ... etc.

If I were twiddling my thumbs, this is what I'd write and the way I'd write
it. However, I actually have work to do, so is there some overpaid jock
somewhere willing to do this? perl would be desired. ;-)

----------------------------------
Bruce T. Harvey (Special Projects)
----------------------------------------
bth@comcast.net -- bruceh@routescape.com
410-236-5721 (cell) -- 410-403-2390 (off.)
-------------------------------------------
Insight Distribution Systems / CoAxis, Inc.
Hunt Valley, Maryland U.S.A. 21031-1422
-------------------------------------------

-----Original Message-----
From: Holger.VanKoll@SWISSCOM.COM [mailto:Holger.VanKoll@SWISSCOM.COM]
Sent: Wednesday, March 19, 2003 11:50 AM
To: aix-l@Princeton.EDU
Subject: [aix-l] AW: Scripting: processing stanzas

Hello Simon,

I dont understand what you want to do.

Could you give an example?

Regards, Holger

        -----Ursprüngliche Nachricht-----
        Von: Green, Simon [mailto:Simon.Green@EU.ALTRIA.COM]
        Gesendet: Mi 19.03.2003 16:20
        An: aix-l@Princeton.EDU
        Cc:
        Betreff: Scripting: processing stanzas

        Is there any utility analogous to getopt that can be used to process
input
        data in stanza format? Has to be useable with a Korn shell script,
as I
        don't speak Perl or anything clever like that.

        If not, any convenient tricks? I'm writing something from scratch,
so I
        have complete control over the data format but stanzas would be
simple to
        maintain.

        Simon Green
        Altria ITSC Europe s.a.r.l.

        AIX-L Archive at http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2
        AIX FAQ at http://www.faqs.org/faqs/aix-faq/

        N.B. Unsolicited email from vendors will seldom be appreciated.



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:40 EDT