• 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 Variables and Global Variables on Debian 12

  • 01:43 lsb_release -a
  • 01:57 cd /etc/asterisk
  • 02:11 vim extensions.conf
  • 05:19 sudo asterisk -rvvvvvvvvvvvvvvvvv
  • 05:27 dialplan reload
{{postValue.id}}

To use Asterisk Dialplan Variables and Global Variables on Debian 12

Introduction:

Asterisk is an open-source telephony platform which are classified in to two types of variables: Dialplan Variables and Global Variables. These variables are used to store and manipulate data within the Asterisk dialplan and can be accessed and modified during the call processing.

Dialplan Variables: Dialplan variables are variables that are defined and used within a specific context or extension in the Asterisk dialplan. They are used to store temporary data that is relevant to a particular call or call leg. Dialplan variables are scoped to the context in which they are defined and are typically used to pass information between different parts of the dialplan.

Global Variables: Global variables are variables that have a global scope and are accessible from anywhere within the Asterisk dialplan. They are typically used to store configuration settings, constants, or values that need to be shared across multiple contexts or extensions. Global variables are defined in the Asterisk configuration files, such as extensions.conf or other included configuration files.

Procedure

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

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm

Step 2: Go to asterisk location by using following command.

root@linuxhelp:~# cd /etc/asterisk/

Step 3: Edit the extensions.conf file for create dialplan variable and global variable by using following command.

root@linuxhelp:/etc/asterisk# vim extensions.conf

Step 4: Login to the Asterisk CLI Console by using following command.

root@linuxhelp:/etc/asterisk# sudo asterisk -rvvvvvvvvvvvvvv
Asterisk 20.4.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 detail
s.
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.4.0 currently running on linuxhelp (pid = 97146)

Step 5: Reload the Dialplan by using following command.

linuxhelp*CLI> dialplan reload
Dialplan reloaded.
  == Setting global variable 'GLOBAL_VAR' to 'This is a global variable'
    -- Time to scan old dialplan and merge leftovers back into the new: 0.000011
 sec
    -- Time to restore hints and swap in new dialplan: 0.000019 sec
    -- Time to delete the old dialplan: 0.000013 sec
    -- Total time merge_contexts_delete: 0.000043 sec
    -- pbx_config successfully loaded 1 contexts (enable debug for details).

Step 6: Check the 112 extension as shown in below image.

snap 1

linuxhelp*CLI> 
    -- Executing [110@internal:1] Set("PJSIP/112-00000027", "my_variable=Hello, 
World") in new stack
    -- Executing [110@internal:2] Dial("PJSIP/112-00000027", "PJSIP/110, 20") in
 new stack
    -- Called PJSIP/110
    -- PJSIP/110-00000028 is ringing
    -- Nobody picked up in 20000 ms
    -- Executing [110@internal:3] Playback("PJSIP/112-00000027", "sorry_didnt_ge
t") in new stack
       > 0x7fcb8c05ce90 -- Strict RTP learning after remote address set to: 192.
168.6.102:8000
       > 0x7fcb8c05ce90 -- Strict RTP switching to RTP target address 192.168.6.
102:8000 as source
    -- <PJSIP/112-00000027> Playing 'sorry_didnt_get.ulaw' (language 'en')
    -- Executing [110@internal:4] Hangup("PJSIP/112-00000027", "Hello, World") i
n new stack
[Sep 27 03:31:41] WARNING[98130][C-00000020]: pbx_builtins.c:926 pbx_builtin_han
gup: Invalid cause given to Hangup(): "Hello, World"
  == Spawn extension (internal, 110, 4) exited non-zero on 'PJSIP/112-00000027'

Step 7: Check the 110 extension as shown in below image.

snap 2

linuxhelp*CLI> 
    -- Executing [112@internal:1] NoOp("PJSIP/110-00000029", "This is a global v
ariable") in new stack
    -- Executing [112@internal:2] Dial("PJSIP/110-00000029", "PJSIP/112, 20") in
 new stack
    -- Called PJSIP/112
    -- PJSIP/112-0000002a is ringing
    -- Nobody picked up in 20000 ms
    -- Executing [112@internal:3] Playback("PJSIP/110-00000029", "sorry_didnt_ge
t") in new stack
       > 0x7fcb8c05ce70 -- Strict RTP learning after remote address set to: 210.
18.155.184:51546
       > 0x7fcb8c05ce70 -- Strict RTP qualifying stream type: audio
       > 0x7fcb8c05ce70 -- Strict RTP switching source address to 192.168.6.102:
51546
    -- <PJSIP/110-00000029> Playing 'sorry_didnt_get.ulaw' (language 'en')
    -- Executing [112@internal:4] Hangup("PJSIP/110-00000029", "") in new stack
  == Spawn extension (internal, 112, 4) exited non-zero on 'PJSIP/110-00000029'

Step 8: Exit the Asterisk Console by using following command.

linuxhelp*CLI> exit
Asterisk cleanly ending (0).
Executing last minute cleanups

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to use Asterisk Dialplan Variables and Global Variables on Debian 12. Your feedback is much welcome.

Tags:
matthew
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is the main difference between Dialplan Variables and Global Variables in Asterisk?

A

The main difference is their scope. Dialplan Variables are scoped to a specific context or extension within the dialplan and are used for temporary data relevant to a single call or call leg. Global Variables, on the other hand, have a global scope and can be accessed from anywhere within the Asterisk configuration, making them suitable for storing shared data and configuration settings.

Q

How do I set a value for a Dialplan Variable in Asterisk?

A

You can set a Dialplan Variable using the Set application within a specific extension in your Asterisk dialplan. For example:
plaintextCopy code
exten => 123,1,Set(my_variable=42)
This sets a Dialplan Variable named my_variable with a value of 42 within extension 123.

Q

Can Dialplan Variables be used to share data between different contexts in Asterisk?

A

Dialplan Variables are primarily scoped to the context or extension in which they are defined. However, you can use channel variables or Global Variables to share data between different contexts or extensions.

Q

How are Global Variables defined in Asterisk, and where are they typically configured?

A

Global Variables are defined in the Asterisk configuration files, often within a [globals] section in the extensions.conf file or other included configuration files. Here's an example of defining a Global Variable:
plaintextCopy code
[globals] my_global_variable = 100

Q

What is the advantage of using Global Variables in Asterisk?

A

Global Variables provide a way to centralize and manage shared data and configuration settings across your Asterisk configuration. They can be accessed from any part of the dialplan, making them useful for storing constants, configuration parameters, or values that need to be accessed globally.

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 Sebastian ?
How to change non required to required field in SuiteCRM Custom/Default Modules

How to change not required to the required field in SuiteCRM Custom/Default Modules?

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.