• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial 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
7650

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

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.

Related Tutorials in How to use Asterisk Dialplan Variables and Global Variables on Debian 12

Related Tutorials in How to use Asterisk Dialplan Variables and Global Variables on Debian 12

How to install Gparted on Debian 9.0
How to install Gparted on Debian 9.0
Sep 13, 2017
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Sep 19, 2018
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to install qBittorrent on Debian 9.0
How to install qBittorrent on Debian 9.0
Sep 8, 2017
How to Install FileZilla in Debian
How to Install FileZilla in Debian
Nov 29, 2016
How to install Nmap on Debian 9.0
How to install Nmap on Debian 9.0
Sep 9, 2017
How to Install Laravel in Debian
How to Install Laravel in Debian
Dec 7, 2016
How to install and configure Asterisk in CentOS
How to install and configure Asterisk in CentOS
Jul 19, 2016

Related Forums in How to use Asterisk Dialplan Variables and Global Variables on Debian 12

Related Forums in How to use Asterisk Dialplan Variables and Global Variables on Debian 12

MariaDB
ryan class=
E: Unable to locate package mariadb-server
Sep 18, 2017
Linux
AadrikaAnshu class=
How to add timestamps to history On Any Linux Machine
Jun 18, 2019
vim
jacob class=
Change true vi-compatible editor from Debian Vim-compatible
Nov 8, 2021
debian
anandaamatya class=
RedNotebook on Debian buster
Jun 30, 2020
Ubuntu
Kirin class=
Videos Always Micro-Shutter
Mar 8, 2019
debian
luke class=
workbench for debian
May 26, 2017
debian
teddybarax class=
Softwae installation problem
Aug 24, 2020
debian
colbyvance class=
Trouble Installing Debian 10.8.0 (Gnome)
Feb 28, 2021

Related News in How to use Asterisk Dialplan Variables and Global Variables on Debian 12

Related News in How to use Asterisk Dialplan Variables and Global Variables on Debian 12

Debian IceDove kicks the bucket after Thunderbird revisits Debian Repositories
Debian IceDove kicks the bucket after Thunderbird revisits Debian Repositories
Feb 28, 2017
Mass update of Jessie - A better alternative to new version?
Mass update of Jessie - A better alternative to new version?
May 8, 2017
Debian 9.2 ‘Stretch’ OS is here, download distro now
Debian 9.2 ‘Stretch’ OS is here, download distro now
Oct 9, 2017
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 Gibbson ?
How do i run both nginx and apache in same instance on centos

Hi...,

my server is based centos operating system and my webserver is already running on Apache.... i need to run both apache and nginx on same instance ... please help me to implement this concept...

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.