Execute an Asterisk CLI command in an Asterisk manager session
The Asterisk CLI is accessible through the manager API. All of the CLI commands can be passed through using the “Command subset” feature. For example,
to dump the current dialplan, send the following:
SEND:
ACTION: Command
command: show dialplan
RECEIVE:
Response: Follows
[ Context ‘MeetMe’ created by ‘pbx_config’ ]
‘s’ => 1. Answer() [pbx_config]
2. Wait(1) [pbx_config]
3. MeetMe(|DM) [pbx_config]
[ Context ‘default’ created by ‘pbx_config’ ]
‘h’ => 1. Goto(Hungup|${extension}|1) [pbx_config]
‘_.’ => 1. SetVar(extension=${EXTEN}) [pbx_config]
2. Macro(dial_agi_ver.1.0.0|${EXTEN}|${channel}) [pbx_config]
‘_mysqluid-.’ => 1. Macro(dial_out_ver.1.0.0|${EXTEN}) [pbx_config]
[ Context ‘parkedcalls’ created by ‘res_features’ ]
‘*8’ => 1. Park() [res_features]
–END COMMAND–
Note: This response here has been severely truncated from the actual response I received, but I decided not to give out my customers’ phone numbers if you don’t mind. This is just to give you an idea of what it does. This is not intended to be a good example of a dialplan, please consult the dialplan examples for that.
Back
Hint
Be careful to use just one Return (\r\n) after “Action” and doublereturn (\r\n\r\n) after “Command”.
Example (in PHP):
fputs($socket, “Command: show dialplan\r\n\r\n”);