[SOLVED] call feature code or dial from script or CLI

Hi, my goal is to activate a time condition when a specific extension is off-line.
My office very often closes after the time set in the TimeGroup, and I would like to override it using a cron script that monitors a softphone status installed on a pc that is surely online until the office closes

I wrote this bash script to monitor the status of the that extension (12) and the status of the time condition (feature code *275), but I cannot “dial” this feature code from the script.

I tried “originate SIP/12 extension *275@from-internal”, but it doesn’t work

Can some help me please?
Thank you in advance for any answer

this is the script

#!/bin/bash

#Check softphone status whose estension is 12
PC=`/usr/sbin/asterisk -r -x "sip show peers" | grep "12/12" |awk '{print $2}'`;
#if online is: 192.168.1.10
#if offline is: (Unspecified)

#Check Time Condition status whose feature code is *275 
STATO=`/usr/sbin/asterisk -r -x "core show hint *275" |awk 'NR==1{split($3,a,":");print a[2]}'`;
#if activated is: InUse
#if deactivated is: Idle

echo $PC
echo $STATO


if [ "$PC" != "192.168.1.10" ] &&  [ "$STATO" == "Idle" ]; then
#pc is off-line	
echo "try to set  NightTime"
/usr/sbin/asterisk -r -x "originate SIP/12 extension *275@from-internal"
elif [ "$PC" == "192.168.1.10" ] && [ "$STATO" == "InUse" ]; then
echo "try to set DayTime"
/usr/sbin/asterisk -r -x "originate SIP/12 extension *275@from-internal"
else
echo ""
fi

Solved
The solution might be useful to someone.

The dial command for the cli is included in module chan_oss.so

Before to load the module, edit oss.conf
change:

to:

and save
(I tried to set overridecontext = yes to pass a command like: console dial *275@timeconditions-toggles , but it doesn’t work, or better, worked only once)

edit modules.conf
change:

to:

and save
(so next time you reboot the module is loaded)

now from cli:

try if it works (*275 is my Time Condition feature code)

in freepbx you should see
Current Override: Temporary Override matching state

redo

*CLI>console dial *275 in freepbx you should see
Current Override: No Override

schedule the script in cron like ( I set it to run every 30 seconds ):

This is the new script:
check_sip_ext-2notte.pl

 #!/bin/bash

    #Check softphone status whose estension is 12
    PC=`/usr/sbin/asterisk -r -x "sip show peers" | grep "12/12" |awk '{print $2}'`;
    #if online is: 192.168.1.10
    #if offline is: (Unspecified)

    #Check Time Condition status whose feature code is *275
    STATO=`/usr/sbin/asterisk -r -x "core show hint *275" |awk 'NR==1{split($3,a,":");print a[2]}'`;
    #if activated is: InUse
    #if deactivated is: Idle

# on production comment all echo lines below 
    echo $PC
    echo $STATO


    if [ "$PC" != "192.168.1.10" ] &&  [ "$STATO" == "Idle" ]; then
    #pc is off-line   
    echo "try to set  NightTime"
    /usr/sbin/asterisk -r -x "console dial *275"
    elif [ "$PC" == "192.168.1.10" ] && [ "$STATO" == "InUse" ]; then
    echo "try to set DayTime"
    /usr/sbin/asterisk -r -x "console dial *275"
    else
    echo ""
    fi

Don’t forget to make the file executable :wink:

Note: on Pc I installed a very lightweight SIP softphone (microsip)

Rudy