<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/Using+The+include+and+exec+Constructs">Using The include and exec Constructs</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~lmadsen">Leif Madsen</a>
    </h4>
        <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" > <br>h4. Enabling #exec Functionality <br></td></tr>
            <tr><td class="diff-changed-lines" >The #exec construct is not enabled by default, as it has some risks both in terms of performance and security. To enable this functionality, go to the *asterisk.conf* configuration file (by default located in <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">_</span>/etc/asterisk<span class="diff-added-chars"style="background-color: #dfd;">_</span>)</span> and set *execincludes=yes* in the *\[options\]* section. By default both the *\[options\]* section heading and the *execincludes=yes* option have been commented out, you you&#39;ll need to remove the semicolon from the beginning of both lines. <br></td></tr>
            <tr><td class="diff-unchanged" >{note} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>There are two other constructs we can use within our configuration files. They are <b>&#35;include</b> and <b>&#35;exec</b>.</p>

<p>The <b>&#35;include</b> construct tells Asterisk to read in the contents of another configuration file, and act as though the contents were at this location in this configuration file. The syntax is <b>&#35;include filename</b>, where <b>filename</b> is the name of the file you'd like to include. This construct is most often used to break a large configuration file into smaller pieces, so that it's more manageable.</p>

<p>The <b>&#35;exec</b> takes this one step further. It allows you to execute an external program, and place the output of that program into the current configuration file. The syntax is <b>&#35;exec program</b>, where <b>program</b> is the name of the program you'd like to execute.</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><h4><a name="UsingTheincludeandexecConstructs-Enabling%23execFunctionality"></a>Enabling #exec Functionality</h4>
<p>The #exec construct is not enabled by default, as it has some risks both in terms of performance and security. To enable this functionality, go to the <b>asterisk.conf</b> configuration file (by default located in <em>/etc/asterisk</em>) and set <b>execincludes=yes</b> in the <b>[options]</b> section. By default both the <b>[options]</b> section heading and the <b>execincludes=yes</b> option have been commented out, you you'll need to remove the semicolon from the beginning of both lines.</p></td></tr></table></div>

<p>Let's look at example of both constructs in action.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: javascript; gutter: false"><![CDATA[[section-name]
setting=true
#include otherconfig.conf      ; include another configuration file
#exec otherprogram             ; include output of otherprogram]]></script>
</div></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/Using+The+include+and+exec+Constructs">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4817459&revisedVersion=9&originalVersion=8">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Using+The+include+and+exec+Constructs?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>