Subj : Basic script help
To   : Avon
From : Zip
Date : Fri Aug 06 2021 12:30 pm

Hello Avon!

On 06 Aug 2021, Avon said the following...
Av>  Zi> Are there any specific filename patterns which can be detected for ea
Av>  Zi> of those?
Av>
Av> Yes I want one script to run then check for *.GAL files and if found in
Av> my inbound then run the GD maint
Av>
Av> I'd like to add additional such tests to the script so it tests for *.FHR
Av> files and runs For Honour  etc :)

Then you could try something like this in your BBS user's crontab (crontab -e as the BBS user):

SHELL=/bin/bash

* * * * * if [ ! -z "$(find /mystic/echomail/in/ -xdev -type f -iname '*.gal'
-print -quit)" ]; then /path/to/gal_maint.sh; fi

* * * * * if [ ! -z "$(find /mystic/echomail/in/ -xdev -type f -iname '*.fhr'
-print -quit)" ]; then /path/to/fhr_maint.sh; fi

This would run the checks every minute.

Or place it in the system-wide crontab directory, e.g. in a file /etc/cron.d/custom_bbs, but then you'll have to specify the username of the BBS user om each crontab line, too:

SHELL=/bin/bash

* * * * * bbs if [ ! -z "$(find /mystic/echomail/in/ -xdev -type f -iname '*.gal' -print -quit)" ]; then /path/to/gal_maint.sh; fi

* * * * * bbs if [ ! -z "$(find /mystic/echomail/in/ -xdev -type f -iname '*.fhr' -print -quit)" ]; then /path/to/fhr_maint.sh; fi

(Username "bbs" in the example.)

If the scripts output anything (information or error messages), that will be sent to the "bbs" user's local mailbox, or forwarded (e.g. to an e-mail address) if there is one specified in /etc/aliases:

bbs: [email protected]

If you edit /etc/aliases, make sure to run 'newaliases' afterwards to be on the safe side (that it catches the change).

Oh, and the reason for SHELL= in the crontabs are that cron usually defaults to /bin/sh for the shell to run the *cron line* with, and on some systems /bin/sh nowadays point to /bin/dash, a different and simpler shell, so if you have some complex expressions on the cron line, it might barf...

Your *scripts*, though, will execute their code with the shell specified on their first line (#!/bin/something, usually #!/bin/bash).

Hope this helps!

Best regards
Zip

--- Mystic BBS v1.12 A47 2021/08/05 (Linux/64)
* Origin: Star Collision BBS, Uppsala, Sweden (21:1/202)