#exec, #piktexec, #pexec

What if you want to run a process but don't really want to #include anything at that point? You can use this

#include "/dev/null" [<proc>]
Or, you can use its effective equivalent
#exec "/dev/null" [<proc>]
Because you have specified a file (/dev/null), [<proc>] will only be run if you are doing a 'piktc -I' (update #include/#verbatim files) operation.

If you want to run [<proc>] every time (whether or not you are using the piktc -I option), you would use

#exec [<proc>]
One possible use of #exec would be to run some external process that updates a series of #include files referenced later on in the PIKT configuration.

#piktexec (and its equivalent, #pexec) is similar to #exec except that for the [<proc>], you specify any legitimate Pikt statement sequence.  For example, you might do this (in systems.cfg):

sudo
        members
#verbatim <systems/sudo_systems.cfg> [/pikt/bin/piktc -xI +C
          "=ls /etc/sudoers 2>/dev/null | =grep sudoers >/dev/null &&
          =hostname" -H down 2>/dev/null]
#piktexec "/dev/null" [if =wednesday =mailmsg1(review the sudo group,
                      REMINDER, =piktadmin) fi]
The above says to populate the sudo host group with machines identified as sudo machines by the presence of an /etc/sudoers file.  Then, in the #piktexec directive, if today is Wednesday, e-mail a short reminder message, "review the sudo group," to the PIKT sysadmin.  Because of the "/dev/null", this reminder is only sent (on Wednesdays) during any 'piktc -I' program run.

Note that you may use PIKT macros (for example, =mailmsg1()) in your #piktexec [<proc>].

Another example:

#pexec "/dev/null" [=remind(2001, 6, 30, reactivate the Foo alarm,
                            REMINDER, =piktadmin)]
If you left out the "/dev/null", and if this were June 30, 2001, the reminder message would be sent and resent with every piktc run that day, which is probably not what you want.

#exec and #piktexec were inspired by the felt need to deal with the general reminder problem.  You have this capability, in alarms.cfg, by means of something like the =remind() macro.  #piktexec extends this sort of capability to all the other PIKT .cfg files.

It will be interesting to discover other uses for #exec, #piktexec, and the whole idea of running processes from within the PIKT configuration.

Using #exec and #piktexec correctly requires subtlety and care on your part, especially when it comes to proper quoting.  A good rule of thumb:  Avoid using single quotes (') anywhere within a #piktexec directive.

Refer to the Samples section for examples.

prev page 1st page next page
 
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
Learn about
the Pikt script
begin, end &
rule sections