• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to use Asterisk Dialplan Functions on Oracle Linux 9.3

  • 00:33 cat /etc/os-release
  • 00:46 cd /etc/asterisk/
  • 00:58 vim extensions.conf
  • 01:30 asterisk -rvvvvvvvvvvvvvvv
  • 01:46 dialplan reload
  • 03:16 core show functions
{{postValue.id}}

To Use Asterisk Dialplan Functions On Oracle Linux 9.3

Introduction

Asterisk functions are very similar to functions in many programming languages. Functions are Sophisticated subroutines that help you manipulate data in various ways. Callable from within Dialplan and Asterisk's various interfaces.

Procedure Steps

Step 1: Check the OS version by using the below command.

[root@linuxhelp ~]#  cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3

Step 2: Goto the following location by using the below command..

[root@linuxhelp ~]# cd /etc/asterisk/
[root@linuxhelp asterisk]#

Step 3: Edit the extensions.conf file for use dialplan functions by using the below command.

root@linuxhelp:/etc/asterisk# vim extensions.conf
[internal]
exten => 110,1,NoOp(Result for my function: ${CALLERID(all)})
same => n,Dial(PJSIP/110, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()

exten => 111,1,NoOp(Print the context)
same => n,Dial(PJSIP/111, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()

Step 4: Login to the asterisk console by using the below command.

[root@linuxhelp asterisk]# asterisk -rvvvvvvvvvvvvvvvvv
Asterisk 20.5.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.5.0 currently running on linuxhelp (pid = 7590)
linuxhelp*CLI>

Step 5: Reload the dialplan by using the below command.

linuxhelp*CLI> dialplan reload
Dialplan reloaded.
    -- Time to scan old dialplan and merge leftovers back into the new: 0.000039 sec
    -- Time to restore hints and swap in new dialplan: 0.000007 sec
    -- Time to delete the old dialplan: 0.000009 sec
    -- Total time merge_contexts_delete: 0.000055 sec
    -- pbx_config successfully loaded 1 contexts (enable debug for details).

Step 6: Make a Call to Check Dialplan Functions by using Softphone Softwares.

linuxhelp*CLI> 
    -- Executing [110@internal:1] NoOp("PJSIP/111-0000000b", "Result for my function: "linuxhelp2" <111>") in new stack
    -- Executing [110@internal:2] Dial("PJSIP/111-0000000b", "PJSIP/110, 20") in new stack
    -- Called PJSIP/110
    -- PJSIP/110-0000000c is ringing
    -- Nobody picked up in 20000 ms
    -- Executing [110@internal:3] Playback("PJSIP/111-0000000b", "sorry_didnt_get") in new stack
       > 0x7f48000305a0 -- Strict RTP learning after remote address set to: 192.168.6.102:4010
    -- <PJSIP/111-0000000b> Playing 'sorry_didnt_get.ulaw' (language 'en')
       > 0x7f48000305a0 -- Strict RTP switching to RTP target address 192.168.6.102:4010 as source
    -- Executing [110@internal:4] Hangup("PJSIP/111-0000000b", "") in new stack
  == Spawn extension (internal, 110, 4) exited non-zero on 'PJSIP/111-0000000b'

Step 7: Check all the functions of asterisk by using the below command.

linuxhelp*CLI> core show functions
Installed Custom Functions:
--------------------------------------------------------------------------------
AMI_CLIENT            AMI_CLIENT(loginname,field)          Checks attributes of manager accounts
ARRAY                 ARRAY(var1[,var2[,...][,varN]])      Allows setting multiple variables at once.
AST_SORCERY           AST_SORCERY(module_name,object_type  Get a field from a sorcery object
CALLERID              CALLERID(datatype[,CID])             Gets or sets Caller*ID data on the channel.
CDR                   CDR(name[,options])                  Gets or sets a CDR variable.
CDR_PROP              CDR_PROP(name)                       Set a property on a channel's CDR.
CONFBRIDGE            CONFBRIDGE(type,option)              Set a custom dynamic bridge, user, or menu profile on a channel for the ConfBridge application using the same options available in confbridge.conf.
CONFBRIDGE_CHANNELS   CONFBRIDGE_CHANNELS(type,conf)       Get a list of channels in a ConfBridge conference.
CONFBRIDGE_INFO       CONFBRIDGE_INFO(type,conf)           Get information about a ConfBridge conference.
CONNECTEDLINE         CONNECTEDLINE(datatype[,i])          Gets or sets Connected Line data on the channel.
CSV_QUOTE             CSV_QUOTE(string)                    Quotes a given string for use in a CSV file, escaping embedded quotes as necessary
DEVICE_STATE          DEVICE_STATE(device)                 Get or Set a device state.
EVAL                  EVAL(variable)                       Evaluate stored variables
EXCEPTION             EXCEPTION(field)                     Retrieve the details of the current dialplan exception.
FEATURE               FEATURE(option_name)                 Get or set a feature option on a channel.
FEATUREMAP            FEATUREMAP(feature_name)             Get or set a feature map to a given value on a specific channel.
FIELDNUM              FIELDNUM(varname,delim,value)        Return the 1-based offset of a field in a list
FIELDQTY              FIELDQTY(varname,delim)              Count the fields with an arbitrary delimiter
FILTER                FILTER(allowed-chars,string)         Filter the string to include only the allowed characters
HASH                  HASH(hashname[,hashkey])             Implementation of a dialplan associative array
HASHKEYS              HASHKEYS(hashname)                   Retrieve the keys of the HASH() function.
HINT                  HINT(extension[@context][,options])  Get the devices set for a dialplan hint.
KEYPADHASH            KEYPADHASH(string)                   Hash the letters in string into equivalent keypad numbers.
LEN                   LEN(string)                          Return the length of the string given.
LISTFILTER            LISTFILTER(varname,delim,value)      Remove an item from a list, by name.
LOCAL                 LOCAL(varname)                       Manage variables local to the gosub stack frame.
LOCAL_PEEK            LOCAL_PEEK(n,varname)                Retrieve variables hidden by the local gosub stack frame.
LTRIM                 LTRIM(string)                        Trim leading whitespace in a string
MESSAGE               MESSAGE(argument)                    Create a message or read fields from a message.
MESSAGE_DATA          MESSAGE_DATA(argument)               Read or write custom data attached to a message.
PASSTHRU              PASSTHRU([string])                   Pass the given argument back as a value.
PJSIP_DIAL_CONTACTS   PJSIP_DIAL_CONTACTS(endpoint[,aor[,  Return a dial string for dialing all contacts on an AOR.
PJSIP_DTMF_MODE       PJSIP_DTMF_MODE()                    Get or change the DTMF mode for a SIP call.
PJSIP_ENDPOINT        PJSIP_ENDPOINT(name,field)           Get information about a PJSIP endpoint
PJSIP_HEADER          PJSIP_HEADER(action,name[,number])   Gets headers from an inbound PJSIP channel. Adds, updates or removes the specified SIP header from an outbound PJSIP channel.
PJSIP_HEADERS         PJSIP_HEADERS([prefix])              Gets the list of SIP header names from an INVITE message.
PJSIP_HEADER_PARAM    PJSIP_HEADER_PARAM(header_name,para  Get or set header/URI parameters on a PJSIP channel.
PJSIP_MEDIA_OFFER     PJSIP_MEDIA_OFFER(media)             Media and codec offerings to be set on an outbound SIP channel prior to dialing.
PJSIP_MOH_PASSTHROUG  PJSIP_MOH_PASSTHROUGH()              Get or change the on-hold behavior for a SIP call.
PJSIP_PARSE_URI       PJSIP_PARSE_URI(uri,type)            Parse an uri and return a type part of the URI.
PJSIP_RESPONSE_HEADE  PJSIP_RESPONSE_HEADER(action,name[,  Gets headers of 200 response from an outbound PJSIP channel.
PJSIP_RESPONSE_HEADE  PJSIP_RESPONSE_HEADERS([prefix])     Gets the list of SIP header names from the 200 response of INVITE message.
PJSIP_SEND_SESSION_R  PJSIP_SEND_SESSION_REFRESH([update_  W/O: Initiate a session refresh via an UPDATE or re-INVITE on an established media session
POP                   POP(varname[,delimiter])             Removes and returns the last item off of a variable containing delimited text
PUSH                  PUSH(varname[,delimiter])            Appends one or more values to the end of a variable containing delimited text
QUEUE_EXISTS          QUEUE_EXISTS([queuename])            Check if a named queue exists on this server
QUEUE_GET_CHANNEL     QUEUE_GET_CHANNEL(queuename[,positi  Return caller at the specified position in a queue.
QUEUE_MEMBER          QUEUE_MEMBER([queuename],option[,in  Provides a count of queue members based on the provided criteria, or updates a queue member's settings.
QUEUE_MEMBER_COUNT    QUEUE_MEMBER_COUNT(queuename)        Count number of members answering a queue.
QUEUE_MEMBER_LIST     QUEUE_MEMBER_LIST(queuename)         Returns a list of interfaces on a queue.
QUEUE_MEMBER_PENALTY  QUEUE_MEMBER_PENALTY(queuename,inte  Gets or sets queue members penalty.
QUEUE_VARIABLES       QUEUE_VARIABLES(queuename)           Return Queue information in variables.
QUEUE_WAITING_COUNT   QUEUE_WAITING_COUNT([queuename])     Count number of calls currently waiting in a queue.
QUOTE                 QUOTE(string)                        Quotes a given string, escaping embedded quotes as necessary
REDIRECTING           REDIRECTING(datatype[,i])            Gets or sets Redirecting data on the channel.
REGEX                 REGEX("regular expression" string)   Check string against a regular expression.
REPLACE               REPLACE(varname,find-chars[,replace  Replace a set of characters in a given string with another character.
RTRIM                 RTRIM(string)                        Trim trailing whitespace in a string
SHIFT                 SHIFT(varname[,delimiter])           Removes and returns the first item off of a variable containing delimited text
STACK_PEEK            STACK_PEEK(n,which[,suppress])       View info about the location which called Gosub
STRBETWEEN            STRBETWEEN(varname,insert-string)    Inserts a substring between each character in a string.
STRFTIME              STRFTIME([epoch][,timezone[,format]  Returns the current date/time in the specified format.
STRPTIME              STRPTIME(datetime,timezone,format)   Returns the epoch of the arbitrary date/time string structured as described by the format.
STRREPLACE            STRREPLACE(varname,find-string[,rep  Replace instances of a substring within a string with another string.
TESTTIME              TESTTIME(date,time[,zone])           Sets a time to be used with the channel to test logical conditions.
TOLOWER               TOLOWER(string)                      Convert string to all lowercase letters.
TOUPPER               TOUPPER(string)                      Convert string to all uppercase letters.
TRIM                  TRIM(string)                         Trim leading and trailing whitespace in a string
UNSHIFT               UNSHIFT(varname[,delimiter])         Inserts one or more values to the beginning of a variable containing delimited text
VM_INFO               VM_INFO(mailbox[@context],attribute  Returns the selected attribute from a mailbox.
70 custom functions installed.

Conclusion

We have reached the end of this article. In this guide, we have walked you through the steps required to use Asterisk Dialplan Functions on Oracle Linux 9.3. Your feedback is much welcome.

Tags:
isaac
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is an Asterisk dialplan function?

A

An Asterisk dialplan function is a built-in feature that allows you to perform various tasks and manipulate data within the Asterisk dialplan. These functions enable you to work with variables, strings, numbers, and more.

Q

How do I use dialplan functions in Asterisk?

A

To use a dialplan function, you typically enclose it in `${}` and provide any required arguments. For example, `${FUNCNAME(argument)}`.

Q

What are some common dialplan functions?

A

Common dialplan functions include `SET`, `EXTEN`, `CALLERID`, `STRFTIME`, `LEN`, `TIMEOUT`, and many more. These functions serve different purposes, such as setting variables, formatting time, and manipulating strings.

Q

Can I create custom dialplan functions?

A

Yes, you can create custom dialplan functions using Asterisk's "FUNC_ODBC" or by writing custom dialplan code in extensions.conf. This allows you to implement custom logic and data retrieval.

Q

How do I retrieve the current extension in Asterisk?

A

You can use the `${EXTEN}` dialplan function to retrieve the current extension being dialed in Asterisk.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Lucas ?
Various options in Top command

Am using Top command only to view the load average, what are the various options in Top command..??

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.