7.1. asterisk -rx "command"

The simplest way to control Asterisk from an external shell or application is to issue the command asterisk with the option -rx followed by the CLI command. Any CLI command may be entered from the system shell in this fashion.

Example

Say you wanted to see the dialplan for extension 23 in the context [my-phones]; you would do this with asterisk -rx "dialplan show 23@my-phones" entered in the shell:
root@molokai:~>asterisk -rx "dialplan show 23@my-phones"
[ Context 'my-phones' created by 'pbx_config' ]
  '23' =>           1. Wait(1)                                    [pbx_config]
                    2. Answer()                                   [pbx_config]
                    3. Playback(hello-world)                      [pbx_config]
                    4. Wait(1)                                    [pbx_config]
                    5. Hangup()                                   [pbx_config]

-= 1 extension (5 priorities) in 1 context. =-
root@molokai:~>