Estranho Patrick, pois testei comigo e funcionou perfeitamente.<div><br></div><div>Testa com calma...<br><div><br></div><div>Mesmo sendo uma dúvida de PHP não foge do contexto, pois trata-se de algo pertinente.</div><div><br>
</div><div>Amanhã eu printo a tela do browser e te envio...</div><div><br></div><div>Vamos resolver isso meu caro...</div><div><br></div><div>Att,<br><br><div class="gmail_quote">Em 5 de novembro de 2012 20:45, Patrick EL Youssef <span dir="ltr">&lt;<a href="mailto:wushumasters@gmail.com" target="_blank">wushumasters@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 text="#000000" bgcolor="#FFFFFF">
    Alex,<br>
    <br>
    Traz o mesmo retorno de antes.<br>
    <br>
    Mas sem problemas vou tentar me virar aqui até porque é uma duvida
    de php e não de asterisk.<br>
    <br>
    Valeu mesmo assim a ajuda de todos.<br>
    <br>
    Patrick<br>
    <br>
    <div>Em 05-11-2012 16:47, Alex Sander
      escreveu:<br>
    </div><div><div class="h5">
    <blockquote type="cite">Patrick, veja se este código resolve seu problema:<br>
      <br>
      &lt;?php<br>
      $socket = fsockopen(&quot;127.0.0.1&quot;,&quot;5038&quot;, $errno, $errstr, 10);<br>
          if (!$socket) {<br>
              echo &quot;$errstr ($errno)\n&quot;;<br>
          } else {<br>
                      fputs($socket, &quot;Action: Login\r\n&quot;);<br>
                      fputs($socket, &quot;UserName: usuario\r\n&quot;);<br>
                      fputs($socket, &quot;Secret: senha\r\n\r\n&quot;);<br>
      <br>
                      fputs($socket, &quot;Action: Command\r\n&quot;);<br>
                      fputs($socket, &quot;Command: sip show peers\r\n\r\n&quot;);<br>
                      fputs($socket, &quot;Action: Logoff\r\n\r\n&quot;);<br>
          $i = 1;<br>
          while (!feof($socket)) {<br>
                         $linha[$i] = fgets($socket);<br>
                         $valida = substr($linha[$i],0,4);<br>
                         if($valida == &#39;Name&#39;)<br>
                              {<br>
                                      $p1 = $i;<br>
                              }<br>
                         if($valida == &#39;--EN&#39;)<br>
                              {<br>
                                      $p2 = $i;<br>
                              }<br>
                         $i++;<br>
                  }<br>
      <br>
              fclose($socket);<br>
              for($i=$p1; $i&lt;$p2; $i++)<br>
                      echo $linha[$i].&#39;&lt;br&gt;&#39;;<br>
                  }<br>
      ?&gt;<br>
      <br>
      <div class="gmail_quote">
        Em 5 de novembro de 2012 14:42, Daviramos Roussenq Fortunato <span dir="ltr">&lt;<a href="mailto:daviramosrf@gmail.com" target="_blank">daviramosrf@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">
          Patrick,
          <div><br>
          </div>
          <div>  Sua dúvida é mais PHP e Asterisk.</div>
          <div><br>
          </div>
          <div>  Primeiro, desenhe o HTML do modelo da tabela que você
            quer, depois faça ela ser gerada dinamicamente no seu PHP.<br>
            <br>
            <div class="gmail_quote">
              Em 5 de novembro de 2012 12:59, Patrick EL Youssef <span dir="ltr">&lt;<a href="mailto:wushumasters@gmail.com" target="_blank">wushumasters@gmail.com</a>&gt;</span>
              escreveu:
              <div>
                <div><br>
                  <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div text="#000000" bgcolor="#FFFFFF"> Daviramos,<br>
                      <br>
                      Segue o código:<br>
                      <br>
                      <br>
                      <b>&lt;?php</b><b><br>
                      </b><b>exec(&#39;sudo /usr/sbin/asterisk -rx &quot;sip show
                        peers&quot;&#39;, $result);</b><b><br>
                      </b><b><br>
                      </b><b>$count = count($result);</b><b><br>
                      </b><b><br>
                      </b><b>for ($x = 0; $x &lt; $count -1; ++$x) {</b><b><br>
                      </b><b>                echo
                        &quot;&lt;pre&gt;&quot;.$result[$x].&quot;&lt;/pre&gt;&quot;;</b><b><br>
                      </b><b>}</b><b><br>
                      </b><b><br>
                      </b><b>?&gt;</b><br>
                      <br>
                      No caso exclui a última linha e com o
                      &quot;&lt;pre&gt;&quot; tenho a mesma saida do cli, mas pra
                      jogar em uma tabela para dar um tratamento melhor
                      realmente não to conseguindo. Se tiver alguma dica
                      agradeço.<br>
                      <br>
                      Valeu,<br>
                      Patrick<br>
                      <br>
                      <div>Em 01-11-2012 17:12, Daviramos Roussenq
                        Fortunato escreveu:<br>
                      </div>
                      <div>
                        <div>
                          <blockquote type="cite">Patrick, 
                            <div><br>
                            </div>
                            <div>  Posso ajudar sim, mas mandei o e-mail
                              direto para Lista para Ficar documentado.</div>
                            <div><br>
                            </div>
                            <div>  Mande o seu código para que possamos
                              opinar sobre possíveis soluções.<br>
                              <br>
                              <div class="gmail_quote"> Em 1 de novembro
                                de 2012 13:16, Patrick EL Youssef <span dir="ltr">&lt;<a href="mailto:wushumasters@gmail.com" target="_blank">wushumasters@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 text="#000000" bgcolor="#FFFFFF">
                                    Daviramos,<br>
                                    <br>
                                    Consegue me ajudar com isso se não
                                    for pedir.<br>
                                    <br>
                                    Seu código eu mudei um pouco e
                                    consegui a saída que queria porém
                                    queria jogar para uma tabela, pensei
                                    em usar o explode mas alguns campos
                                    não são preenchidos dos peers como
                                    por exemplo ACL, ai pensei aqui e
                                    não achei um jeito de resolver.<br>
                                    <br>
                                    Você chegou a fazer isso?<br>
                                    <br>
                                    Valeu,<br>
                                    Patrick<br>
                                    <div>Em 01-11-2012 10:24, Daviramos
                                      Roussenq Fortunato escreveu:<br>
                                    </div>
                                    <blockquote type="cite">Patrick,
                                      <div><br>
                                      </div>
                                      <div>  De uma olhada em <a href="http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+SIPpeers" target="_blank">http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+SIPpeers</a></div>

                                      <div><br>
                                      </div>
                                      <div>  Eu quando uso comando
                                        direto como está fazendo: sip
                                        show peers, eu não uso o
                                        MANAGER, uso direto do console
                                        mesmo, segue exemplo:</div>
                                      <div><br>
                                      </div>
                                      <div><br>
                                      </div>
                                      <div>&lt;?</div>
                                      <div>
                                        <div>exec(&#39;/usr/sbin/asterisk
                                          -rx &quot;sip show peers&quot;&#39;,
                                          $result);</div>
                                        <div>reset($result);</div>
                                        <div>while (key($result) !==
                                          null) {</div>
                                      </div>
                                      <div> 
                                        printf(&quot;%s-%s&quot;,key($result),current($result));</div>
                                      <div>  next($result);</div>
                                      <div>}</div>
                                      <div><br>
                                      </div>
                                      <div>?&gt;</div>
                                      <div><br>
                                      </div>
                                      <div><br>
                                      </div>
                                      <div><br>
                                        <div class="gmail_quote">Em 1 de
                                          novembro de 2012 10:14, Sylvio
                                          Jollenbeck <span dir="ltr">&lt;<a href="mailto:sylvio.jollenbeck@gmail.com" target="_blank">sylvio.jollenbeck@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">Patrick,<br>
                                            <br>
                                            Dentro do while, use a
                                            função strpos do php.<br>
                                            <br>
                                            Abs<br>
                                            <br>
                                            Sylvio Jollenbeck<br>
                                            <br>
                                            <div class="gmail_quote">
                                              <div>
                                                <div>2012/11/1 Patrick
                                                  EL Youssef <span dir="ltr">&lt;<a href="mailto:wushumasters@gmail.com" target="_blank">wushumasters@gmail.com</a>&gt;</span><br>
                                                </div>
                                              </div>
                                              <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                                <div>
                                                  <div>
                                                    <div text="#000000" bgcolor="#FFFFFF">
                                                      Pessoal,<br>
                                                      <br>
                                                      Quem mexe bem com
                                                      o manager e puder
                                                      me ajudar. Estou
                                                      executando comando
                                                      &quot;sip show peers&quot;
                                                      via php porém ele
                                                      me retorna sempre
                                                      as mensagens do
                                                      proprio manager
                                                      junto do comando:<br>
                                                      <br>
                                                      <span>Asterisk
                                                        Call Manager/1.2<span> </span></span><br>
                                                      <span>Response:
                                                        Success<span> </span></span><br>
                                                      <span>Message:
                                                        Authentication
                                                        accepted<span> </span></span><br>
                                                      <br>
                                                      <span>Event:
                                                        FullyBooted<span> </span></span><br>
                                                      <span>Privilege:
                                                        system,all<span> </span></span><br>
                                                      <span>Status:
                                                        Fully Booted<span> </span></span><br>
                                                      <br>
                                                      <span>Response:
                                                        Follows<span> </span></span><br>
                                                      <span>Privilege:
                                                        Command<span> </span></span><br>
                                                      <span>Name/username
                                                        Host Dyn
                                                        Forcerport ACL
                                                        Port Status
                                                        Description
                                                        Realtime<span> </span></span><br>
                                                      <span>2000/2000
                                                        (Unspecified) D
                                                        N A 0 UNKNOWN<span> </span></span><br>
                                                      <span>2001/2001 <a href="tel:192.168.1.131" value="+551921681131" target="_blank">192.168.1.131</a>
                                                        D N 5060
                                                        UNREACHABLE<span> </span></span><br>
                                                      <span>2</span><span>
                                                        sip peers
                                                        [Monitored: 0
                                                        online, 2
                                                        offline
                                                        Unmonitored: 0
                                                        online, 0
                                                        offline]<span> </span></span><br>
                                                      <span>--END
                                                        COMMAND--<span> </span></span><br>
                                                      <br>
                                                      <span>Response:
                                                        Goodbye<span> </span></span><br>
                                                      <span>Message:
                                                        Thanks for all
                                                        the fish.<span>
                                                        </span></span><br>
                                                      <br>
                                                      Tem como eu só
                                                      pegar a saída do
                                                      comando mesmo. Meu
                                                      código php é esse:<br>
                                                      <br>
                                                      $socket =
                                                      fsockopen(&quot;127.0.0.1&quot;,&quot;5038&quot;,
                                                      $errno, $errstr,
                                                      10);<br>
                                                          if (!$socket)
                                                      {<br>
                                                              echo
                                                      &quot;$errstr
                                                      ($errno)\n&quot;;<br>
                                                          } else {<br>
                                                                     
                                                      fputs($socket,
                                                      &quot;Action:
                                                      Login\r\n&quot;);<br>
                                                                     
                                                      fputs($socket,
                                                      &quot;UserName:
                                                      usuario\r\n&quot;);<br>
                                                                     
                                                      fputs($socket,
                                                      &quot;Secret:
                                                      senha\r\n\r\n&quot;);<br>
                                                      <br>
                                                                     
                                                      fputs($socket,
                                                      &quot;Action:
                                                      Command\r\n&quot;);<br>
                                                                     
                                                      fputs($socket,
                                                      &quot;Command: sip show
                                                      peers\r\n\r\n&quot;);<br>
                                                                     
                                                      fputs($socket,
                                                      &quot;Action:
                                                      Logoff\r\n\r\n&quot;);<br>
                                                                  <br>
                                                          while
                                                      (!feof($socket)) {<br>
                                                                        
                                                      echo
                                                      fgets($socket),&#39;&lt;br&gt;&#39;;<br>
                                                                  }<br>
                                                                  <br>
                                                             
                                                      fclose($socket);<br>
                                                                  }<br>
                                                      <br>
                                                      Obrigado,<br>
                                                      Patrick<br>
                                                    </div>
                                                    <br>
                                                  </div>
                                                </div>
_______________________________________________<br>
                                                KHOMP Inovação: External
                                                Board Series<br>
                                                Módulos de 1/2 rack e 1U
                                                para todas as interfaces
                                                e soluções Asterisk e
                                                FreeSWITCH.<br>
                                                Tenha a External Series
                                                Experience na sua
                                                aplicação. Visite <a href="http://www.khomp.com" target="_blank">www.khomp.com</a><br>
_______________________________________________<br>
                                                DIGIVOICE  Fabricante de
                                                Placas de Voz e Channel
                                                Bank<br>
                                                20 anos de experiência
                                                com E1(R2/ISDN), FXS,
                                                FXO e GSM<br>
                                                Centro Treinamento -
                                                Curso de PABX IP -
                                                 Asterisk  - Site  <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a><br>
                                                ________<br>
                                                YEALINK: Telefones IP e
                                                VídeoPhones IP com o
                                                melhor custo/benefício
                                                do mercado.<br>
                                                email: <a href="mailto:yealink@commlogik.com.br" target="_blank">yealink@commlogik.com.br</a>
                                                | <a href="http://www.commlogik.com.br" target="_blank">www.commlogik.com.br</a>
                                                | <a href="tel:%2811%29%205503-1011" value="+551155031011" target="_blank">(11)

                                                  5503-1011</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="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a><br>
                                              </blockquote>
                                            </div>
                                            <br>
                                            <br>
_______________________________________________<br>
                                            KHOMP Inovação: External
                                            Board Series<br>
                                            Módulos de 1/2 rack e 1U
                                            para todas as interfaces e
                                            soluções Asterisk e
                                            FreeSWITCH.<br>
                                            Tenha a External Series
                                            Experience na sua aplicação.
                                            Visite <a href="http://www.khomp.com" target="_blank">www.khomp.com</a><br>
_______________________________________________<br>
                                            DIGIVOICE  Fabricante de
                                            Placas de Voz e Channel Bank<br>
                                            20 anos de experiência com
                                            E1(R2/ISDN), FXS, FXO e GSM<br>
                                            Centro Treinamento - Curso
                                            de PABX IP -  Asterisk  -
                                            Site  <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a><br>
                                            ________<br>
                                            YEALINK: Telefones IP e
                                            VídeoPhones IP com o melhor
                                            custo/benefício do mercado.<br>
                                            email: <a href="mailto:yealink@commlogik.com.br" target="_blank">yealink@commlogik.com.br</a>
                                            | <a href="http://www.commlogik.com.br" target="_blank">www.commlogik.com.br</a>
                                            | <a href="tel:%2811%29%205503-1011" value="+551155031011" target="_blank">(11)

                                              5503-1011</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="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a><br>
                                          </blockquote>
                                        </div>
                                        <br>
                                        <br clear="all">
                                        <div><br>
                                        </div>
                                        -- <br>
                                        Atenciosamente<br>
                                        Daviramos Roussenq Fortunato<br>
                                      </div>
                                      <br>
                                      <fieldset></fieldset>
                                      <br>
                                      <pre>_______________________________________________
KHOMP Inovação: External Board Series
Módulos de 1/2 rack e 1U para todas as interfaces e soluções Asterisk e FreeSWITCH.
Tenha a External Series Experience na sua aplicação. Visite <a href="http://www.khomp.com" target="_blank">www.khomp.com</a>
_______________________________________________
DIGIVOICE  Fabricante de Placas de Voz e Channel Bank
20 anos de experiência com E1(R2/ISDN), FXS, FXO e GSM
Centro Treinamento - Curso de PABX IP -  Asterisk  - Site  <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a>
________
YEALINK: Telefones IP e VídeoPhones IP com o melhor custo/benefício do mercado.
email: <a href="mailto:yealink@commlogik.com.br" target="_blank">yealink@commlogik.com.br</a> | <a href="http://www.commlogik.com.br" target="_blank">www.commlogik.com.br</a> | <a href="tel:%2811%29%205503-1011" value="+551155031011" target="_blank">(11) 5503-1011</a>
______________________________________________
Para remover seu email desta lista, basta enviar um email em branco para <a href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org" target="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a></pre>

                                    </blockquote>
                                    <br>
                                  </div>
                                </blockquote>
                              </div>
                              <br>
                              <br clear="all">
                              <div><br>
                              </div>
                              -- <br>
                              Atenciosamente<br>
                              Daviramos Roussenq Fortunato<br>
                            </div>
                          </blockquote>
                          <br>
                        </div>
                      </div>
                    </div>
                    <br>
                    _______________________________________________<br>
                    KHOMP Inovação: External Board Series<br>
                    Módulos de 1/2 rack e 1U para todas as interfaces e
                    soluções Asterisk e FreeSWITCH.<br>
                    Tenha a External Series Experience na sua aplicação.
                    Visite <a href="http://www.khomp.com" target="_blank">www.khomp.com</a><br>
                    _______________________________________________<br>
                    DIGIVOICE  Fabricante de Placas de Voz e Channel
                    Bank<br>
                    20 anos de experiência com E1(R2/ISDN), FXS, FXO e
                    GSM<br>
                    Centro Treinamento - Curso de PABX IP -  Asterisk  -
                    Site  <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a><br>
                    ________<br>
                    YEALINK: Telefones IP e VídeoPhones IP com o melhor
                    custo/benefício do mercado.<br>
                    email: <a href="mailto:yealink@commlogik.com.br" target="_blank">yealink@commlogik.com.br</a> | <a href="http://www.commlogik.com.br" target="_blank">www.commlogik.com.br</a>
                    | <a href="tel:%2811%29%205503-1011" value="+551155031011" target="_blank">(11)
                      5503-1011</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="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a><br>
                  </blockquote>
                </div>
              </div>
            </div>
            <div>
              <div>
                <br>
                <br clear="all">
                <div><br>
                </div>
                -- <br>
                Atenciosamente<br>
                Daviramos Roussenq Fortunato<br>
              </div>
            </div>
          </div>
          <br>
          _______________________________________________<br>
          KHOMP Inovação: External Board Series<br>
          Módulos de 1/2 rack e 1U para todas as interfaces e soluções
          Asterisk e FreeSWITCH.<br>
          Tenha a External Series Experience na sua aplicação. Visite <a href="http://www.khomp.com" target="_blank">www.khomp.com</a><br>
          _______________________________________________<br>
          DIGIVOICE  Fabricante de Placas de Voz e Channel Bank<br>
          20 anos de experiência com E1(R2/ISDN), FXS, FXO e GSM<br>
          Centro Treinamento - Curso de PABX IP -  Asterisk  - Site  <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a><br>
          ________<br>
          YEALINK: Telefones IP e VídeoPhones IP com o melhor
          custo/benefício do mercado.<br>
          email: <a href="mailto:yealink@commlogik.com.br" target="_blank">yealink@commlogik.com.br</a>
          | <a href="http://www.commlogik.com.br" target="_blank">www.commlogik.com.br</a>
          | (11) 5503-1011<br>
          ______________________________________________<br>
          Para remover seu email desta lista, basta enviar um email em
          branco para <a href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org" target="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a><br>
        </blockquote>
      </div>
      <br>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
KHOMP Inovação: External Board Series
Módulos de 1/2 rack e 1U para todas as interfaces e soluções Asterisk e FreeSWITCH.
Tenha a External Series Experience na sua aplicação. Visite <a href="http://www.khomp.com" target="_blank">www.khomp.com</a>
_______________________________________________
DIGIVOICE  Fabricante de Placas de Voz e Channel Bank
20 anos de experiência com E1(R2/ISDN), FXS, FXO e GSM
Centro Treinamento - Curso de PABX IP -  Asterisk  - Site  <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a>
________
YEALINK: Telefones IP e VídeoPhones IP com o melhor custo/benefício do mercado.
email: <a href="mailto:yealink@commlogik.com.br" target="_blank">yealink@commlogik.com.br</a> | <a href="http://www.commlogik.com.br" target="_blank">www.commlogik.com.br</a> | (11) 5503-1011
______________________________________________
Para remover seu email desta lista, basta enviar um email em branco para <a href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org" target="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a></pre>

    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
KHOMP Inovação: External Board Series<br>
Módulos de 1/2 rack e 1U para todas as interfaces e soluções Asterisk e FreeSWITCH.<br>
Tenha a External Series Experience na sua aplicação. Visite <a href="http://www.khomp.com" target="_blank">www.khomp.com</a><br>
_______________________________________________<br>
DIGIVOICE  Fabricante de Placas de Voz e Channel Bank<br>
20 anos de experiência com E1(R2/ISDN), FXS, FXO e GSM<br>
Centro Treinamento - Curso de PABX IP -  Asterisk  - Site  <a href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a><br>
________<br>
YEALINK: Telefones IP e VídeoPhones IP com o melhor custo/benefício do mercado.<br>
email: <a href="mailto:yealink@commlogik.com.br">yealink@commlogik.com.br</a> | <a href="http://www.commlogik.com.br" target="_blank">www.commlogik.com.br</a> | (11) 5503-1011<br>
______________________________________________<br>
Para remover seu email desta lista, basta enviar um email em branco para <a href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a><br></blockquote></div>
<br></div></div>