<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/2033/1/7/_/styles/combined.css?spaceKey=AST&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/~mdavenport">Malcolm Davenport</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>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 <span class="diff-added-words"style="background-color: #dfd;">(by default located in /etc/asterisk)</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'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>#include</b> and <b>#exec</b>.</p>
<p>The <b>#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>#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>#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>#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>Enabling #exec Functionality<br/>
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 /etc/asterisk) 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.</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=7&originalVersion=6">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Using+The+include+and+exec+Constructs?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>