How to use a feature code to start different scripts depending of the connected extension

hi community

i am testing asterisk on a raspberry pi (raspbx-11-11-2019, pjsip) and i hope for your help to finish my feature codes project.

i can start a pythonscript with a feature code:

globals_custom.conf
DYNAMIC_FEATURES = test7

features_applicationmap_custom
test7 => #7,peer,gosub(start_script,start,1())

extensions_custom.conf
[start_script]
exten => start,1,System(sudo /usr/local/sbin/testscript1.py)
same => n,Return()

Now i hope for your help to extend this so, that i can start different scripts depending of the connected extension.
21 in call with 10
10 sends #7
execute testscript21.py

22 in call with 10
10 sends #7
execute testscript22.py

thank you for any ideas.

kind regards
hoi

Read and act on ${CALLERID}. You may need to import it based on the bridged peer, or copy it using an _ prefix.

hi david,

thank you for the tip, i need to check it this weekend.
maybe you know a link to an examle i can use for study?

thank you and kind regards
hoi

extensions_custom.conf
[start_script]
exten => start,1,ExecIf(["{CALLERID(num)}"=“21”]?System(sudo /usr/local/sbin/testscript21.py))
exten => start,2,ExecIf(["{CALLERID(num)}"=“22”]?System(sudo /usr/local/sbin/testscript22.py))
same => n,Return()

that works for me, thanks for your help.

If there is a lot of commonality between the 2 scripts, maybe something like:

[start_script]
        exten => start,1,system(sudo /usr/local/sbin/testscript.py ${CALLERID(num)})
        same => n,return()

would make sense.

Also, if Asterisk is running as root, the 'sudo' is superfluous. If not, maybe you can write the script so it does not need sudo.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.