<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/2042/1/7/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Connecting+to+the+CLI">Connecting to the CLI</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~lmadsen">Leif Madsen</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Add a tip that says you can use this outside the CLI<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >server*CLI&gt; quit <br>{noformat} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br> <br>{tip:title=Executing Command Outside Of CLI} <br>You can execute an Asterisk command from outside the CLI: <br>{code} <br>$ asterisk -rx &quot;reload&quot; <br>{code} <br> <br>{code} <br>$ asterisk -rx &quot;help&quot; | grep -i &quot;sip&quot; <br>{code} <br>{tip}  <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>First, let's show you how to connect to the Asterisk command-line interface. As you should recall from the installation, Asterisk typically runs in the background as a service or daemon. If the Asterisk service is already running, type the command below to connect to its command-line interface.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[root@server ~]# asterisk -r
</pre>
</div></div>


<p>The &#45;r parameter tells the system that you want to re-connect to the Asterisk service. If the reconnection is successful, you'll see something like this:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[root@server ~]# asterisk -r
Asterisk version, Copyright (C) 1999 - 2010 Digium, Inc. and others.
Created by Mark Spencer &lt;markster@digium.com&gt;
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 version currently running on server (pid = 11187)
server*CLI&gt;
</pre>
</div></div>

<p>Notice the <b>&#42;CLI&gt;</b> text? That's your Asterisk command-line prompt. All of the Asterisk CLI commands take the form of <b>module action parameters....</b> For example, type <b>core show uptime</b> to see how long Asterisk has been running.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>server*CLI&gt; core show uptime
System uptime: 1 hour, 34 minutes, 17 seconds
Last reload: 1 hour, 34 minutes, 17 seconds
</pre>
</div></div>

<p>You can use the built-in help to get more information about the various commands. Simply type <b>core show help</b> at the Asterisk prompt for a full list of commands, or <b>core show help command</b> for help on a particular command.</p>

<p>If you'd like to exit the Asterisk console and return to your shell, just use the <b>quit</b> command from the CLI. Such as:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>server*CLI&gt; quit
</pre>
</div></div>


<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Executing Command Outside Of CLI</b><br />You can execute an Asterisk command from outside the CLI:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: java; gutter: false"><![CDATA[
$ asterisk -rx "reload"
]]></script>
</div></div>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: java; gutter: false"><![CDATA[
$ asterisk -rx "help" | grep -i "sip"
]]></script>
</div></div></td></tr></table></div> 
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://wiki.asterisk.org/wiki/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Connecting+to+the+CLI">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4817527&revisedVersion=11&originalVersion=10">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Connecting+to+the+CLI?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>