Asterisk cmd Backticks


Execute a shell command and save the result as a variable.

Description of application:


<VARNAME> - The name of the variable to be set.
<command> - The shell command to execute; be sure to provide the full path to the command. I used sh, but I think any language will do.

Description of function:


<command> - Same as above.


  • *CLI> show application BACKTICKS
  • *CLI> show function BACKTICKS

This application is not distributed as part of Asterisk.

Return value

Returns the resulting string.


  • application:
exten => s,1,BACKTICKS(FOO|/your/path/ ; sets FOO to result, see here for more info

  • function:
exten => s,1,Set(FOO=${BACKTICKS(/your/path/ ${arg1} ${arg2})}) ; sets FOO to result, I only could get the "function" to take arguments

if [ -e "/some/path/$1/caller-$2.ulaw" ]; then x=1; fi /* see man test for info on the if argument */
echo $x

The above takes two args, checks for the existence of the file, if it exists return 1, else return 0; i.e. the resulting value of foo.


Download from You can download it from
Follow his install instructions except:
  1. you may want to save app_backticks.c to /usr/src/asterisk
  2. for his step 3, cd /usr/src/asterisk first and then execute /usr/src/asterisk/contrib/scripts/astxs -install app_backticks.c
This script doesn't work with asterisk >= 1.8 .
A working version to use with asterisk >= 1.8 can be found here

See also

Created by: Blumagic, Last modification: Thu 08 of Mar, 2012 (17:30 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+