Upgrade 3CX to v18 and get it hosted free!

Asterisk cmd ExecIf

Author image

Synopsis

Executes dialplan application, conditionally.

Usage

Version 1.2 and 1.4

ExecIF (<expr>|<app>|<data>)

Version 1.4.24.1

ExecIF (<expr>?<app>|<data>)

Version 1.6

ExecIf(expression?appiftrue(args)[:appiffalse(args)])

Description

If <expr> is true, execute and return the result of <app>(<data>).
If <expr> is true, but <app> is not found, then the application will return a non-zero value.

It is important not to have any spaces as it does not seem to like that (gives a could not find application if spaces are present). Also, if you don’t use quotation marks and the first value contains spaces (ex.: SYSTEMSTATUS=”internal server error”), it’ll always evaluate to true (ExecIf will evaluate as ExecIf(internal?Background)).

Also note that the separator between the expression is a comma or a vertical bar, not a question mark (as is the case with GotoIf)(Version 1.2 and 1.4).
As of 1.6 the syntax is inline with GotoIf and the 1.2/1.4 syntax will give you errors.

Example

Version 1.2 and 1.4

exten => s,n,ExecIf($["${SYSTEMSTATUS}" = "SUCCESS"]|Background|dictate/playback)

Version 1.4.24.1

exten => s,n,ExecIf($["${SYSTEMSTATUS}" = "SUCCESS"]?Background|dictate/playback)

Version 1.6

exten => s,n,ExecIf($["${SYSTEMSTATUS}" = "SUCCESS"]?Background(dictate/playback))

See Also


Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.