Command to execute external script?

Hello Everyone, Does anyone know how to use DTMF tones to run a command, to execute external script?

···

Thanks, David

“Laws that forbid the carrying of arms…disarm only those who are neither inclined nor determined to commit crimes. Such laws make things worse for the assaulted and better for the assailants; they serve rather to encourage than prevent homicides, for an unarmed man may be attacked with greater confidence than an armed one.”

Thomas Jefferson

  1. write the bash script or program (you can execute programs too; I
    suggest creating a subdirectory in the /etc/asterisk
    directory…doug calls it ‘local’, I usually call it ‘scripts’),
    debug it, make sure to ‘chmod 755 scriptname’.
  2. Edit /etc/asterisk/rpt.conf.
  3. Go to the [functionsxxxx] stanza for the node you’re working
    with. Of, if you have just one function stanza, go there.
  4. Insert a line, for instance:
    85=cmd,/fully/qualified/path/to/script
  5. save rpt.conf, restart asterisk.
    Now, when you key up the node, and use *85, that script will run.
    It should be noted that functions are decoded using the least number
    of digits. So, if you have:
    8=cmd,somescript
    81=cmd,somescript
    811=cmd,somescript
    which script gets executed is left as an exercise. Really very simple and flexible. BB
    wb0yle/w2fuv
···

On 1/17/2018 6:41 PM, David Shaw wrote:

    Hello Everyone, Does anyone know how to use DTMF

tones to run a command, to execute external script?

1 Like

Thanks to everyone for the help. All the inputs work great.

David

···

On Wed, Jan 17, 2018 at 5:27 PM, Bryan D. Boyle bdboyle@bdboyle.com wrote:

On 1/17/2018 6:41 PM, David Shaw wrote:

    Hello Everyone, Does anyone know how to use DTMF

tones to run a command, to execute external script?

1. write the bash script or program (you can execute programs too; I

suggest creating a subdirectory in the /etc/asterisk
directory…doug calls it ‘local’, I usually call it ‘scripts’),
debug it, make sure to ‘chmod 755 scriptname’.

2. Edit /etc/asterisk/rpt.conf.

3. Go to the [functionsxxxx] stanza for the node you're working

with. Of, if you have just one function stanza, go there.

4. Insert a line, for instance:

85=cmd,/fully/qualified/path/to/script

5. save rpt.conf, restart asterisk.



Now, when you key up the node, and use *85,  that script will run.



It should be noted that functions are decoded using the least number

of digits. So, if you have:

8=cmd,somescript

81=cmd,somescript

811=cmd,somescript



which script gets executed is left as an exercise. 



Really very simple and flexible. 



BB

wb0yle/w2fuv

App_rpt-users mailing list

App_rpt-users@lists.allstarlink.org

http://lists.allstarlink.org/cgi-bin/mailman/listinfo/app_rpt-users

To unsubscribe from this list please visit http://lists.allstarlink.org/cgi-bin/mailman/listinfo/app_rpt-users and scroll down to the bottom of the page. Enter your email address and press the “Unsubscribe or edit options button”

You do not need a password to unsubscribe, you can do it via email confirmation. If you have trouble unsubscribing, please send a message to the list detailing the problem.

Thanks, David

“Laws that forbid the carrying of arms…disarm only those who are neither inclined nor determined to commit crimes. Such laws make things worse for the assaulted and better for the assailants; they serve rather to encourage than prevent homicides, for an unarmed man may be attacked with greater confidence than an armed one.”

Thomas Jefferson

Looking at this reply and trying to get it to work with DTMF, Not very good at Linux but stumbling through and managing. Just need some clarification on some of the steps

So in rpt.conf

[functions]
80=cmd,/etc/asterisk/scripts.conf Or should it be something else?
81=cmd,/etc/asterisk/scripts.conf

So then I would in /etc/asterisk/ make a file scripts ? or a directory?

trying to run two scripts: sudo systemctl stop mmdvm_bridge
sudo systemctl start mmdvm_bridge

Then in /etc/asterisk/scripts.conf I have:
80=cmd,/sudo systemctl stop mmdvm_bridge
81=cmd,/sudo systemctl start mmdvm_bridge

Like I said not a Linux guru but I am trying :upside_down_face:

In CLI I get this error:
NOTICE[598]: app_rpt.c:4084 function_cmd: cmd param = /etc/asterisk/scripts.conf, digitbuf =

Thank You

James

  1. log in to your asterisk box.
  2. type “sudo su -”
  3. type “cd /etc/asterisk”
  4. type “mkdir scripts”
  5. type “chmod 755 scripts”
  6. type “cd scripts”
    (all without the " ", of course)

Then create your shell scripts using a file editor, either “vi” or “nano”.

so, let’s create one to start the mmdvm bridge:

  1. type “vi start_bridge.sh” (press enter key)
  2. type “i” to start inserting text.
  3. type in the following 3 lines, with an enter at the end of each line:

#! /bin/bash
sudo systemctl start mmdvm_bridge
sleep 5

  1. press your esc (escape) key, you will see a “:” at the bottom of the screen.
  2. enter “wq!” without the " " to write out and quit .
  3. type “chmod 755 start_bridge.sh” without the " ".
  4. type “cd …” to go back up to /etc/asterisk

In your functions stanza, the command, say for 80, would be:
80=cmd,/etc/asterisk/scripts/start_bridge.sh

After you edit your rpt.conf, don’t forget to restart asterisk either from the command line or in the asterisk CLI by typing “rpt reload”.

Basically. No guarantee this will work, but it’s what I’ve done for over a decade and works fine. You can call other scripts from within scripts, so, one command can end up reconfiguring your entire asterisk instance.

How to reverse the above is left as an exercise for you to explore.

Bryan
wb0yle/w2fuv
Fall River, MA
Morrisville, PA