<span style='font-family:Verdana'><span style='font-size:12px'>Leandro, agradeço sua resposta.<br /> 
<br /> 
Mas no caso de ser em perl, me complicaria pois depois não conseguiria dar continuidade, pois entendo e pouco de php mas conseguiria me virar.<br /> 
<br /> 
Estou procurando como fazer uma consulta e pegar a variavel pelo set_variable no qual ainda não consegui.<br /> 
<br /> 
Abraços.<br /> 
<br /> 
<p style="margin:0px; padding:0px;" > 
         </p> 
<blockquote style="border-left: 1px solid #CCC; padding-left: 5px; margin-left: 5px; margin-bottom: 0px; margin-top: 0px; margin-right: 0px;" type="cite"> 
        <p style="margin:0px; padding:0px;" > 
                <span style="font-family:Verdana"><span style="font-size:12px">----- Original Message -----</span></span></p> 
        <p style="margin:0px; padding:0px;" > 
                <span style="font-family:Verdana"><span style="font-size:12px">From: Leandro Alves</span></span></p> 
        <p style="margin:0px; padding:0px;" > 
                <span style="font-family:Verdana"><span style="font-size:12px">Sent: 10/04/11 04:37 PM</span></span></p> 
        <p style="margin:0px; padding:0px;" > 
                <span style="font-family:Verdana"><span style="font-size:12px">To: asteriskbrasil@listas.asteriskbrasil.org</span></span></p> 
        <p style="margin:0px; padding:0px;" > 
                <span style="font-family:Verdana"><span style="font-size:12px">Subject: Re: [AsteriskBrasil] RES: AGI no extencions.conf consulta SQL Server</span></span></p> 
        <br /> 
        <div> 
                <p style="margin:0px; padding:0px;" > 
                        Aqui tem exemplos de utilização no asterisk:</p> 
                <div> 
                         </div> 
                <div> 
                        <a href="http://www.asterikast.com/show_notes/sn_3.txt" target="_blank">http://www.asterikast.com/show_notes/sn_3.txt</a><br /> 
                        <br /> 
                        <div class="gmail_quote"> 
                                Em 4 de outubro de 2011 16:35, Leandro Alves <span>&lt;<a href="mailto:thc.leandro@gmail.com" >thc.leandro@gmail.com</a>&gt;</span> escreveu:<br /> 
                                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> 
                                        <div> 
                                                Exemplo de consulta AGI com Perl:</div> 
                                        <div> 
                                                 </div> 
                                        <div> 
                                                #!/usr/bin/perl</div> 
                                        <div> 
                                                print "Content-type:text/html\n\n";</div> 
                                        <div> 
                                                 </div> 
                                        <div> 
                                                use DBI;</div> 
                                        <div> 
                                                 </div> 
                                        <div> 
                                                $username = '';$password = '';$database = '';$hostname = '';</div> 
                                        <div> 
                                                $dbh = DBI-&gt;connect("dbi:mysql:database=$database;" .</div> 
                                        <div> 
                                                &nbsp;"host=$hostname;port=3306", $username, $password);</div> 
                                        <div> 
                                                 </div> 
                                        <div> 
                                                $SQL= "select * from user";</div> 
                                        <div> 
                                                 </div> 
                                        <div> 
                                                $Select = $dbh-&gt;prepare($SQL);</div> 
                                        <div> 
                                                $Select-&gt;execute();</div> 
                                        <div> 
                                                 </div> 
                                        <div> 
                                                while($Row=$Select-&gt;fetchrow_hashref)</div> 
                                        <div> 
                                                {</div> 
                                        <div> 
                                                &nbsp; print "$Row-&gt;{username}</div> 
                                        <div> 
                                                $Row-&gt;{email}";</div> 
                                        <div> 
                                                }</div> 
                                        <br /> 
                                        <div class="gmail_quote"> 
                                                Em 4 de outubro de 2011 14:32, Sylvio Carlos Jollenbeck <span>&lt;<a href="mailto:sylvio.sdr@gmail.com" target="">sylvio.sdr@gmail.com</a>&gt;</span> escreveu: 
                                                <div> 
                                                        <div> 
                                                                 </div> 
                                                        <div class="h5"> 
                                                                <br /> 
                                                                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> 
                                                                        freetds<br /> 
                                                                        <br /> 
                                                                        <br clear="all" /> 
                                                                        # ---------------------------------------------------------------<br /> 
                                                                        <b>Sylvio Carlos Jollenbeck Borin</b><br /> 
                                                                        Gerente de Desenvolvimento<br /> 
                                                                        Akiva Software<br /> 
                                                                        <a href="http://www.akivasoftware.com.br" target="_blank">www.akivasoftware.com.br</a><br /> 
                                                                        # ----------------------------------------------------------------<br /> 
                                                                        <br /> 
                                                                        <br /> 
                                                                        <div class="gmail_quote"> 
                                                                                Em 4 de outubro de 2011 13:45, Tetra Informatica <span>&lt;<a href="mailto:tetra@tetra.srv.br" target="">tetra@tetra.srv.br</a>&gt;</span> escreveu:<br /> 
                                                                                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> 
                                                                                        <div> 
                                                                                                <div> 
                                                                                                         </div> 
                                                                                                <div> 
                                                                                                        <div> 
                                                                                                                <div> 
                                                                                                                        <p class="MsoNormal"> 
                                                                                                                                <font color="navy" face="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial;color:navy">Eu já usei bastante o AGI com acesso ao MySQL e Postgres e prefiro usar ODBC ao invés de código nativo.</span></font></p> 
                                                                                                                        <p class="MsoNormal"> 
                                                                                                                                <font color="navy" face="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial;color:navy">Quanto ao seu problema, acho que fica bem mais simples com o AGI. Só não sei se tem um driver ODBC do SQL Server que rode no Linux.</span></font></p> 
                                                                                                                        <p class="MsoNormal"> 
                                                                                                                                <font color="navy" face="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial;color:navy">abç</span></font></p> 
                                                                                                                        <p class="MsoNormal"> 
                                                                                                                                <font color="navy" face="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial;color:navy">&nbsp;</span></font></p> 
                                                                                                                        <div> 
                                                                                                                                <div align="center" class="MsoNormal" style="text-align:center"> 
                                                                                                                                        <hr align="center" size="2" width="100%" /> 
                                                                                                                                </div> 
                                                                                                                                <p class="MsoNormal"> 
                                                                                                                                        <b><font face="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma;font-weight:bold">De:</span></font></b><font face="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma"> <a href="mailto:eassis@linuxmail.org" target="">eassis@linuxmail.org</a> [mailto:<a href="mailto:eassis@linuxmail.org" target="">eassis@linuxmail.org</a>]<br /> 
                                                                                                                                        <b><span style="font-weight:bold">Enviada em:</span></b> segunda-feira, 3 de outubro de 2011 22:18<br /> 
                                                                                                                                        <b><span style="font-weight:bold">Para:</span></b> <a href="mailto:asteriskbrasil@listas.asteriskbrasil.org" target="">asteriskbrasil@listas.asteriskbrasil.org</a><br /> 
                                                                                                                                        <b><span style="font-weight:bold">Assunto:</span></b> [AsteriskBrasil] AGI no extencions.conf consulta SQL Server</span></font></p> 
                                                                                                                        </div> 
                                                                                                                        <div> 
                                                                                                                                <div> 
                                                                                                                                         </div> 
                                                                                                                                <div> 
                                                                                                                                        <p class="MsoNormal"> 
                                                                                                                                                <font face="Times New Roman" size="3"><span style="font-size:12.0pt">&nbsp;</span></font></p> 
                                                                                                                                        <p style="margin:0px; padding:0px; margin:0cm;margin-bottom:.0001pt"> 
                                                                                                                                                <font face="Verdana" size="1"><span style="font-size:9.0pt;font-family:Verdana">&nbsp;</span></font></p> 
                                                                                                                                        <p class="MsoNormal" style="margin-bottom:12.0pt"> 
                                                                                                                                                <font face="Verdana" size="1"><span style="font-size:9.0pt;font-family:Verdana"><span>Alguem ja fez esse tipo de consulta ?<br /> 
                                                                                                                                                <br /> 
                                                                                                                                                Tenho uma necessidade em conectar um AGI pelo extensions.conf em um banco SQL Server, passando um valor e retornando outro valor.<br /> 
                                                                                                                                                <br /> 
                                                                                                                                                Alguem poderia me mostrar como proceder, pois o que acho no google não me atendeu.<br /> 
                                                                                                                                                <br /> 
                                                                                                                                                Pensei em usar o ODBC mas falaram que o AGI seria mais simples para essa minha necessidade.<br /> 
                                                                                                                                                <br /> 
                                                                                                                                                Atualmente tenho esse tipo de conexão com o Mysql usando:</span></span></font></p> 
                                                                                                                                        <div> 
                                                                                                                                                <p class="MsoNormal"> 
                                                                                                                                                        <span><font face="Verdana" size="1"><span style="font-size:9.0pt;font-family:Verdana">exten =&gt; s,1,MYSQL(Connect connid localhost user senha banco)</span></font></span></p> 
                                                                                                                                        </div> 
                                                                                                                                        <div> 
                                                                                                                                                <p class="MsoNormal"> 
                                                                                                                                                        <span><font face="Verdana" size="1"><span style="font-size:9.0pt;font-family:Verdana">exten =&gt; s,n,MYSQL(Query resultid ${connid} SELECT campo from tabela where campo = condicao);</span></font></span></p> 
                                                                                                                                        </div> 
                                                                                                                                        <div> 
                                                                                                                                                <p class="MsoNormal"> 
                                                                                                                                                        <span><font face="Verdana" size="1"><span style="font-size:9.0pt;font-family:Verdana">exten =&gt; s,n,Mysql(Fetch fetchid ${resultid} resultado)</span></font></span></p> 
                                                                                                                                        </div> 
                                                                                                                                        <div> 
                                                                                                                                                <p class="MsoNormal"> 
                                                                                                                                                        <span><font face="Verdana" size="1"><span style="font-size:9.0pt;font-family:Verdana">exten =&gt; s,n,MYSQL(Disconnect ${connid})</span></font></span></p> 
                                                                                                                                        </div> 
                                                                                                                                        <p class="MsoNormal"> 
                                                                                                                                                <br /> 
                                                                                                                                                <font face="Verdana" size="1"><span style="font-size:9.0pt;font-family:Verdana"><span>Com esse resultado consigo fazer o necessario, agora queria o mesmo só que em um BD SQL Server.<br /> 
                                                                                                                                                <br /> 
                                                                                                                                                Abraços.</span></span></font></p> 
                                                                                                                                </div> 
                                                                                                                        </div> 
                                                                                                                </div> 
                                                                                                        </div> 
                                                                                                </div> 
                                                                                        </div> 
                                                                                        _______________________________________________<br /> 
                                                                                        KHOMP: qualidade em placas de E1, GSM, FXS e FXO para Asterisk.<br /> 
                                                                                        - Hardware com alta disponibilidade de recursos e qualidade KHOMP<br /> 
                                                                                        - Suporte técnico local qualificado e gratuito<br /> 
                                                                                        Conheça a linha completa de produtos KHOMP em <a href="http://www.khomp.com.br" target="_blank">www.khomp.com.br</a><br /> 
                                                                                        _______________________________________________<br /> 
                                                                                        DIGIVOICE: Lider no mercado de placas para Asterisk<br /> 
                                                                                        Único fabricante com Centro de Treinamento especializado.<br /> 
                                                                                        LANÇAMENTO: Channel Bank TDMoE, até 64 canais FXS / FXO.<br /> 
                                                                                        <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a> ou <a href="#" target="">(11)3016-5200</a>.<br /> 
                                                                                        ________<br /> 
                                                                                        GATEWAY GSM-SIP, gateway Lyric VoIP com 2,4 e 6 canais GSM vía tronco SIP<br /> 
                                                                                        Escalável até 240 canáis, Portabilidade Numérica, &nbsp;Balanceamento de Carga, Bilhetagem<br /> 
                                                                                        Confira em <a href="http://www.yx.cl/landing/brasil/lyric_voip_asterisk.org" target="_blank">http://www.yx.cl/landing/brasil/lyric_voip_asterisk.org</a><br /> 
                                                                                        Shop Voip, representante exclusivo: <a href="http://www.shopvoip.com.br" target="_blank">www.shopvoip.com.br</a> ou <a href="#" target="">0800-6021244</a><br /> 
                                                                                        ______________________________________________<br /> 
                                                                                        Para remover seu email desta lista, basta enviar um email em branco para <a href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org" target="">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a></blockquote> 
                                                                        </div> 
                                                                        <br /> 
                                                                        <br /> 
                                                                        _______________________________________________<br /> 
                                                                        KHOMP: qualidade em placas de E1, GSM, FXS e FXO para Asterisk.<br /> 
                                                                        - Hardware com alta disponibilidade de recursos e qualidade KHOMP<br /> 
                                                                        - Suporte técnico local qualificado e gratuito<br /> 
                                                                        Conheça a linha completa de produtos KHOMP em <a href="http://www.khomp.com.br" target="_blank">www.khomp.com.br</a><br /> 
                                                                        _______________________________________________<br /> 
                                                                        DIGIVOICE: Lider no mercado de placas para Asterisk<br /> 
                                                                        Único fabricante com Centro de Treinamento especializado.<br /> 
                                                                        LANÇAMENTO: Channel Bank TDMoE, até 64 canais FXS / FXO.<br /> 
                                                                        <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a> ou <a href="#" target="">(11)3016-5200</a>.<br /> 
                                                                        ________<br /> 
                                                                        GATEWAY GSM-SIP, gateway Lyric VoIP com 2,4 e 6 canais GSM vía tronco SIP<br /> 
                                                                        Escalável até 240 canáis, Portabilidade Numérica, &nbsp;Balanceamento de Carga, Bilhetagem<br /> 
                                                                        Confira em <a href="http://www.yx.cl/landing/brasil/lyric_voip_asterisk.org" target="_blank">http://www.yx.cl/landing/brasil/lyric_voip_asterisk.org</a><br /> 
                                                                        Shop Voip, representante exclusivo: <a href="http://www.shopvoip.com.br" target="_blank">www.shopvoip.com.br</a> ou <a href="#" target="">0800-6021244</a><br /> 
                                                                        ______________________________________________<br /> 
                                                                        Para remover seu email desta lista, basta enviar um email em branco para <a href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org" target="">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a></blockquote> 
                                                        </div> 
                                                </div> 
                                        </div> 
                                        <br /> 
                                        <br clear="all" /> 
                                        <div> 
                                                 </div> 
                                        <font color="#888888">--<br /> 
                                        Att.,&nbsp;</font> 
                                        <div> 
                                                 </div> 
                                        <div> 
                                                <font color="#888888">Leandro Alves<br /> 
                                                </font></div> 
                                </blockquote> 
                        </div> 
                        <br /> 
                        <br clear="all" /> 
                        <div> 
                                 </div> 
                        --<br /> 
                        Att.,&nbsp; 
                        <div> 
                                 </div> 
                        <div> 
                                Leandro Alves</div> 
                </div> 
        </div> 
</blockquote> 
<p style="margin:0px; padding:0px;" > 
         </p> 
<p style="margin:0px; padding:0px;" > 
         </p> 
<br /> 
<span id="editor_signature"><span style="font-family:Verdana; font-size:12px">&nbsp;</span></span></span></span>