=chomp() macro

[posted 2001/11/16]

Here are several fixes for problems you are possibly having with the most recent configs_samples (in PIKT 1.15.0).

For a while, PIKT was finding weird error messages about "'end of file' unexpected" in Urgent.log on Solaris systems.  MessagesScanUrgent runs were generating these errors:

DEBUG:
    PiktUrgentLogScanDebug
        Scan the PIKT Urgent.log for noteworthy entries

        sh: syntax error at line 1: `end of file' unexpected
        sh: syntax error at line 1: `end of file' unexpected
        sh: syntax error at line 1: `end of file' unexpected

The problem traced to /var/adm/messages lines like

Nov 14 08:43:21 paris6 unix: stdout is </sbus@1f,0/zs@f,1100000:a>
  major <29> minor <0>

A pattern match in the 3rd rule of MessagesScanUrgent would intercept such lines and pass them along to the =diskdev() macro for further munging (specifically, to translate device file gobbledygook to human-readable named file systems).

The problem was due to the ">" character in (for example),

    /sbus@1f,0/zs@f,1100000:a>

I might have been able to fix the regexp

                     || $inlin =~ "(/sbus\@[[:digit:]][[:graph:]]+)"

to exclude the ">".  Instead, I revised the =chomp macro as follows:

///////////////////////////////////////////////////////////////////////////////

chomp(S, C)     // sort of like Perl's chomp, chop the last char off of
                // string S if it's a (C)
                if $right((S),1) eq (C)
                        set (S) = $chop((S))
                fi

///////////////////////////////////////////////////////////////////////////////

Before (before 1.15.0), the =chomp macro was defined just to deal with newlines:

///////////////////////////////////////////////////////////////////////////////

chomp(S)        // sort of like Perl's chomp, chop the last char off of
                // string S if it's a newline
                if $right((S),1) eq $newline()
                        set (S) = $chop((S))
                fi

///////////////////////////////////////////////////////////////////////////////

So now, before passing the line along to =devfile(), I just add a =chomp() instruction before it:

                if (    $inlin =~ "(/iommu\@[[:alpha:]][[:graph:]]+)"
                     || $inlin =~ "(/pci\@[[:digit:]][[:graph:]]+)"
                     || $inlin =~ "(/sbus\@[[:digit:]][[:graph:]]+)"
                     || $inlin =~ "(/pseudo/md\@[[:digit:]][[:graph:]]+)"
                     || $inlin =~ "(/io-unit\@[[:alpha:]][[:graph:]]+)"
                   )
                        set $df = $1
                        =chomp($df, ">")
                        set $dd = =diskdev($df)

Problem solved!

Open Hand For more examples, see Developer's Notes.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-02-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
systems revival
script macro