doexec Statement

[posted 2007/04/17]

[Notes (edited slightly) issued with the release of PIKT 1.19.0pre4, which:  added the doexec Pikt script statement.]

When using the pikt '-T' (Test) command-line switch, or if the alarm status is set to 'testing', alarm 'exec' and 'exec wait' statements become effectively 'output' (or 'output mail'), and command strings are reported and/or logged rather than executed.  But what about the following situation?

dmesg_scan(BYPASSES)

        init
                status =piktstatus
                level =piktlevel
                task "Scan the dmesg output for troublesome or noteworthy entries"
                input proc "if [ -e =hstdir/log/dmesg=piktalert=_.bak ]; then
                           =diff =hstdir/log/dmesg=piktalert=_.bak
                           =hstdir/log/dmesg=piktalert | =egrep '>' |
                           =cut -b 3- 2>/dev/null;
                           else =cat =hstdir/log/dmesg=piktalert 2>/dev/null; fi"

        begin
                exec wait "=dmesg | =uniq > =hstdir/log/dmesg=piktalert"

        rule
                [... input processing follows ...]

In the 'begin' section 'exec' statement, the intent is to send dmesg output to a file, which is then used as script input in the 'input proc' statement. In testing mode, the 'exec' would in fact not execute, there would be no saved dmesg output, and the script would be rendered useless.

To fix this, we have added a new script statement, 'doexec', to force command execution in all cases.  If instead you have

                doexec wait "=dmesg | =uniq > =hstdir/log/dmesg=piktalert"

the dmesg output will be written to the file whether or not the script is in testing mode.

So, use 'doexec' where essential to the script operation and ordinary 'exec' where the indicated command execution is optional (or for safety's sake during the script development and testing phase you want a command to be reported rather than executed).

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 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
top log
Pikt script