• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4

  • 00:40 Cat /etc/os-release
  • 00:56 systemctl status asterisk
  • 01:24 cd /etc/asterisk/
  • 01:38 vim pjsip.conf
  • 02:16 vim extensions.conf
  • 03:38 asterisk -rvvvvvvvvvvvvvvv
  • 03:47 dialplan reload
  • 04:12 exit
  • 04:15 vim extensions.conf
  • 04:58 asterisk -rvvvvvvvvvvv
  • 05:06 dialplan reload
7882

To Use Variables And Global Variables Using Asterisk Dialplan Context On Rocky Linux 9.4

Introduction:

Asterisk offers the ability to create customized call flow patterns to effectively manage unexpected changes and improve the efficiency of your communication system. It allows for the utilization of global, shared, and channel-specific variables for command arguments. Additionally, Asterisk includes predefined variables to enhance functionality.

Procedure:

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

[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.4 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.4"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.4 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.4"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.4"

Step 2: Check the status of the Asterisk services by using the below command.

[root@Linuxhelp ~]# systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
     Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
     Active: active (running) since Sun 2024-06-23 23:24:59 IST; 2 weeks 0 days ago
       Docs: man:systemd-sysv-generator(8)
   Main PID: 1224
      Tasks: 39 (limit: 48597)
     Memory: 63.1M
        CPU: 36.087s
     CGroup: /system.slice/asterisk.service
             ├─1221 /bin/sh /usr/sbin/safe_asterisk
             └─5288 /usr/sbin/asterisk -f -vvvg -c

Jun 23 23:24:59 Linuxhelp systemd[1]: Starting LSB: Asterisk PBX...
Jun 23 23:24:59 Linuxhelp asterisk[1140]: Starting asterisk:
Jun 23 23:24:59 Linuxhelp systemd[1]: asterisk.service: Can't open PID file /run/asterisk/asterisk.pid (yet>
Jun 23 23:24:59 Linuxhelp systemd[1]: asterisk.service: Supervising process 1224 which is not our child. We>
Jun 23 23:24:59 Linuxhelp systemd[1]: Started LSB: Asterisk PBX.
Jun 23 23:25:54 Linuxhelp systemd[1]: /run/systemd/generator.late/asterisk.service:30: PIDFile= references >
Jun 23 23:26:17 Linuxhelp systemd[1]: /run/systemd/generator.late/asterisk.service:30: PIDFile= references >
Jul 08 00:33:58 Linuxhelp systemd[1]: /run/systemd/generator.late/asterisk.service:30: PIDFile= references >

Step 3: Move to the Asterisk directory by using the below command.

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

Step 4: Show the endpoints in the pjsip.conf file by using the below command.

[root@Linuxhelp asterisk]# vim pjsip.conf

Step 5: Open extensions.conf file to edit the dialplan using variables by using the below command.

[root@Linuxhelp asterisk]# vim extensions.conf

Step 6: Login to the Asterisk CLI console by using the below command.

[root@Linuxhelp asterisk]# asterisk -rvvvvvvvvvvvvvvv
Asterisk 20.8.1, 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.8.1 currently running on Linuxhelp (pid = 5288)

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

Linuxhelp*CLI> dialplan reload
Dialplan reloaded.
[Jul  8 00:57:58] WARNING[6903]: pbx_config.c:1955 pbx_load_config: ==!!== Unknown directive: ringtime at line 3 of extensions.conf -- IGNORING!!!
        > Time to scan old dialplan and merge leftovers back into the new: 0.000002 sec
        > Time to restore hints and swap in new dialplan: 0.000003 sec
        > Time to delete the old dialplan: 0.000002 sec
        > Total time merge_contexts_delete: 0.000007 sec
        > pbx_config successfully loaded 1 contexts (enable debug for details).

Step 8: Exit from the Asterisk CLI by using the below command.

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

Step 9: Again, open the extension.conf to use channel variable by using the below command.

[root@Linuxhelp asterisk]# vim extensions.conf
[internal]
ringtime=20
exten => 167,1,Set(ring=30)
exten => 167,2,Dial(PJSIP/167,${ring})
exten => 167,3,playback()
exten => 167,4,Hangup()
exten => 168,1,Dial(PJSIP/168,${ringtime})

Step 10: Login to the Asterisk CLI Console and reload the dialplan by using the below command.

[root@Linuxhelp asterisk]# asterisk -rvvvvvvvvvvv
Asterisk 20.8.1, 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.8.1 currently running on Linuxhelp (pid = 5288)
Linuxhelp*CLI> dialplan reload
Dialplan reloaded.
[Jul  8 01:01:22] WARNING[6969]: pbx_config.c:1955 pbx_load_config: ==!!== Unknown directive: ringtime at line 3 of extensions.conf -- IGNORING!!!
        > Time to scan old dialplan and merge leftovers back into the new: 0.000003 sec
        > Time to restore hints and swap in new dialplan: 0.000003 sec
        > Time to delete the old dialplan: 0.000002 sec
        > Total time merge_contexts_delete: 0.000008 sec
        > pbx_config successfully loaded 1 contexts (enable debug for details).

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps how to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4. Your feedback is much welcome.

Tags:
michael
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What are the variables in Asterisk Dialplan?

A

Variables in Asterisk Dialplan are placeholders used to store and manipulate data during call processing. They can hold values such as phone numbers, extensions, or any other relevant information.

Q

How do I define a local variable in the Asterisk Dialplan?

A

You can define a local variable using the Set application:
exten => 1234,1,Set(MYVAR=Hello)
This sets the variable MYVAR to the value "Hello" for the current call.

Q

How do I use a local variable in the Asterisk Dialplan?

A

You can use a local variable by referencing it with ${} syntax:
exten => 1234,n,NoOp(${MYVAR})
This logs the value of MYVAR.

Q

Can I modify a global variable during a call?

A

Yes, you can modify a global variable during a call using the Set application:
exten => 1234,n,Set(GLOBAL(MYGLOBALVAR)=NewValue)

Q

Can I use both local and global variables in the same dialplan?

A

Yes, you can use both local and global variables in the same dialplan. Ensure to distinguish them properly to avoid conflicts.

Related Tutorials in How to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4

Related Tutorials in How to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4

How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
Oct 17, 2022
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 and Configure Mega in Linux
How to Install and Configure Mega in Linux
Jul 19, 2016
How to use Aureport command on Linux
How to use Aureport command on Linux
Nov 28, 2017
How to install and configure Asterisk in CentOS
How to install and configure Asterisk in CentOS
Jul 19, 2016
How to install Development tools on Linux
How to install Development tools on Linux
Jun 12, 2018
How to Install mod_ssl and SSL certificate on Oracle Linux
How to Install mod_ssl and SSL certificate on Oracle Linux
Dec 30, 2021
How to install Nextcloud on Ubuntu 22.04 version
How to install Nextcloud on Ubuntu 22.04 version
Jun 23, 2023

Related Forums in How to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4

Related Forums in How to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4

Linux
jayce class=
shasum command not found
May 5, 2017
Linux
stephan class=
How to list all samba users
Jan 12, 2018
pv command
muhammad class=
pvcreate command not found error
May 9, 2017
Linux
henry class=
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Apr 25, 2017
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
baseer class=
single command to apply setfacl for multiple user at a time
Jan 23, 2018
Linux
beulah class=
What does mean by 0 0 value in fstab file
Jan 2, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018

Related News in How to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4

Related News in How to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4

Anbox, the Android-to-Linux tool the developers have been waiting for
Anbox, the Android-to-Linux tool the developers have been waiting for
Apr 17, 2017
Linus Torvalds stops signing Linux kernel RC tarballs
Linus Torvalds stops signing Linux kernel RC tarballs
May 17, 2017
Capsule8 Launches Linux-Based Container Security Platform
Capsule8 Launches Linux-Based Container Security Platform
Feb 14, 2017
Symantec updates Management console product
Symantec updates Management console product
Nov 22, 2017
Latest Linux driver release feature seven AMD Vega
Latest Linux driver release feature seven AMD Vega
Mar 23, 2017
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
Apr 9, 2019
Microsoft makes its Azure App service now available on Linux Systems
Microsoft makes its Azure App service now available on Linux Systems
Sep 7, 2017
Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 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 Ganesh Konka ?
Zentya 6.1 http proxy configuration

please send link for creating zentyal 6.1 for http proxy and firewall as gateway.

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.