Unwanted Files

In this example, we report the existence of unwanted files--for example, system startup files--also possibly move or delete them.

The SystemFileExist script might send an alert message like the following:

                                PIKT ALERT
                         Thu Jun 13 9:55:43 2003
                                  padua

URGENT:
    SystemFileExist
        Report the existence of unwanted files, and possibly move or remove them

        /etc/rc3.d/S50apache found! doing exec: /usr/bin/mv /etc/rc3.d/S50apache
                                                            /etc/rc3.d/xS50apache

SystemFileExist makes reference to the =files_unwanted_obj macro, which resolves to the name of the FilesUnwanted.obj file.  The script follows.

SystemFileExist         // use this to warn about /etc/nologin files, or
                        // unwanted service startup files (in /etc/rc?.d),
                        // for example

        init
                status =piktstatus
                level =piktlevel
                task "Report the existence of unwanted files,
                      and possibly move or remove them"
                input file "=files_unwanted_obj"
                seps ":"
                dat $name [1]
                dat $cmd  [2]
                keys $name

        rule
                if -e $name
                        set $state = "+"
                        if $cmd eq "."
                                if $state ne %state
                                        =daily(output mail "$name found!", )
                                endif
                        else
                                if %state eq "+"     // existed last run,
                                                     // hence possible rm
                                                     // or mv $cmd failed
                                                     // before
                                        =daily(output mail "$name found!", )
                                else
                                        =outputmail "$name found!
                                                     doing exec: $cmd"
                                        =execwait $cmd
                                endif
                        endif
                else
                        set $state = "-"
                endif

For more examples, see Samples.

 
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
hosts, aliases
& groups