Macro Delay Execution Timer

This script was created to execute a  delay then a command.

Meaning that you issue a command as part of some other simple or complex function and have a delay before it executes a second part or a cancellation of the same.

It could have a multitude of applications once you understand what it is actually doing. But for our example here, it is a simple one.

Our example, we have a light that we use to light our way from the repeater site at night and often someone using it for access to or from the repeater site at night forgets to turn it off. So we need a auto-turn-off for this light-up function.

First,

We are calling the script macro-cmd-timer.sh

If you are using this for many things or nodes, make each instance a unique name with node number and/or special function name.

Create a command for the script in rpt.conf

XXXX=cmd, etc/asterisk/myscripts/macro-cmd-timer.sh

Now our macro for calling the “turn light on” looks like this before we start:

[macro-29283]

55= *9987 *9988# ; (play file” light-on” and switch parallel port pin 5 on)

56= *9989 *9990# ; (play file “light-off” and switch par port pin 5 off)

After:

55= *9987 *9988 *XXXX# ;insert your script command issued above

Edit the script and set the timer in seconds and call the macro that turns it off when the timer has expired.

Make the script 775 ownership.

DOWNLOAD as a file

#!/bin/bash
# mike/kb8jnm – macro-cmd-timer.sh
# create delay / run command
# make a command for this script, call it from a macro string
# set wait time in seconds
sleep 1200
# execute command (calling a macro to shut off the called function)
# format is – rpt fun NODE# CMD#
asterisk -rx “rpt fun 29283 *556
# will clean exit after waiting and executing

# end of file EOF

This simple example is just to show functionality. Use your imagination to fit your need.  Be careful not to put it in a situation where it could be called multiple times in automation.

Barry, G8SAU Used it for this…

I have made a repeater mast head pre-amp control
that users can enable turn on with a DTMF code  eg *51 that gives a boost 
to the RX for a period of 30 mins then reverts to OFF

for those moments that need extra coverage on RX when Fixed user is working 
a Mobile user or an HT user on the edge of coverage, RX wise.

Comments are closed.