Tradução em reference/expect (#670)

* inclusão dos arquivos originais com revisão atualizada

* Tradução em reference/expect

* Update book.xml

* Update constants.xml

* Update examples.xml

* Update reference.xml
This commit is contained in:
Fernando Wobeto
2024-06-28 22:33:42 -03:00
committed by GitHub
parent 1bb0c0e17c
commit b6311e9358
7 changed files with 560 additions and 0 deletions

47
reference/expect/book.xml Normal file
View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 68c2c871505aadf983f16113c5b077b335ce8d76 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
<book xml:id="book.expect" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<?phpdoc extension-membership="pecl" ?>
<title>Expect</title>
<!-- {{{ preface -->
<preface xml:id="intro.expect">
&reftitle.intro;
<para>
Esta extensão permite interagir com processos através do PTY. Pode-se
considerar o uso do <link linkend="wrappers.expect">empacotador <literal>expect://</literal></link>
com as <link linkend="ref.filesystem">funções do sistema de
arquivos</link> que fornecem uma interface mais simples e intuitiva.
</para>
</preface>
<!-- }}} -->
&reference.expect.setup;
&reference.expect.constants;
&reference.expect.examples;
&reference.expect.reference;
</book>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: fbc4ef92fa953823ed73021e462bd291499dc633 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
<section xml:id="expect.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.install;
<para>
&pecl.moved;
&pecl.info;
<link xlink:href="&url.pecl.package;expect">&url.pecl.package;expect</link>.
</para>
<para>
Para usar essas funções você deve compilar o PHP com suporte expect
usando a opção de configuração
<option role="configure">--with-expect[=DIR]</option>.
</para>
<para>
Os usuários do Windows ativarão o <filename>php_expect.dll</filename> dentro
do &php.ini; para usar essas funções.
&pecl.windows.download;
</para>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: aa1da6d204935d3288d1ab49b83401d63b13ed62 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
<appendix xml:id="expect.constants" xmlns="http://docbook.org/ns/docbook">
&reftitle.constants;
&extension.constants;
<variablelist>
<varlistentry xml:id="constant.exp-glob">
<term>
<constant>EXP_GLOB</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Indica que o padrão é uma string no estilo glob.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.exp-exact">
<term>
<constant>EXP_EXACT</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Indica que o padrão é uma string exata.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.exp-regexp">
<term>
<constant>EXP_REGEXP</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Indica que o padrão é uma string no estilo regexp.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.exp-eof">
<term>
<constant>EXP_EOF</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Valor retornado por <function>expect_expectl</function>, quando o EOF é
atingido.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.exp-timeout">
<term>
<constant>EXP_TIMEOUT</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Valor retornado por <function>expect_expectl</function> após o tempo limite de
segundos, especificado no valor de <link linkend="ini.expect.timeout">expect.timeout</link>
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.exp-fullbuffer">
<term>
<constant>EXP_FULLBUFFER</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Valor, retornado por <function>expect_expectl</function> se nenhum padrão foi
correspondido.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</appendix>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 96c9d88bad9a7d7d44bfb7f26c226df7ee9ddf26 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
<chapter xml:id="expect.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="expect.examples-usage">
<title>Exemplos de uso de Expect</title>
<example>
<title>Exemplo de uso de Expect</title>
<para>
Este exemplo se conecta ao host remoto via SSH e imprime o tempo de atividade
remoto.
</para>
<programlisting role="php">
<![CDATA[
<?php
ini_set("expect.loguser", "Off");
$stream = fopen("expect://ssh root@remotehost uptime", "r");
$cases = array (
array (0 => "password:", 1 => PASSWORD)
);
switch (expect_expectl ($stream, $cases)) {
case PASSWORD:
fwrite ($stream, "password\n");
break;
default:
die ("Ocorreu um erro ao conectar-se ao host remoto!\n");
}
while ($line = fgets($stream)) {
print $line;
}
fclose ($stream);
?>
]]>
</programlisting>
</example>
<para>
O exemplo a seguir se conecta ao host remoto, determina se o sistema operacional
instalado é de 32 ou 64 bits e, em seguida, executa a atualização para um pacote específico.
</para>
<example>
<title>Outro Exemplo de Uso de Expect</title>
<programlisting role="php">
<![CDATA[
<?php
ini_set("expect.timeout", -1);
ini_set("expect.loguser", "Off");
$stream = expect_popen("ssh root@remotehost");
while (true) {
switch (expect_expectl ($stream, array (
array ("password:", PASSWORD), // SSH está pedindo uma senha
array ("yes/no)?", YESNO), // SSH está perguntando se deve armazenar a entrada do host
array ("~$ ", SHELL, EXP_EXACT), // Conseguimos o shell!
))) {
case PASSWORD:
fwrite ($stream, "secret\n");
break;
case YESNO:
fwrite ($stream, "yes\n");
break;
case SHELL:
fwrite ($stream, "uname -a\n");
while (true) {
switch (expect_expectl ($stream, array (
array ("~$ ", SHELL, EXP_EXACT), // Conseguimos o shell!
array ("^Linux.*$", UNAME, EXP_REGEXP), // uname -a output
), $match)) {
case UNAME:
$uname .= $match[0];
break;
case SHELL:
// Executa a atualização:
if (strstr ($uname, "x86_64")) {
fwrite ($stream, "rpm -Uhv http://mirrorsite/somepath/some_64bit.rpm\n");
} else {
fwrite ($stream, "rpm -Uhv http://mirrorsite/somepath/some_32bit.rpm\n");
}
fwrite ($stream, "exit\n");
break 2;
case EXP_TIMEOUT:
case EXP_EOF:
break 2;
default:
die ("Ocorreu um erro!\n");
}
}
break 2;
case EXP_TIMEOUT:
case EXP_EOF:
break 2;
default:
die ("Ocorreu um erro!\n");
}
}
fclose ($stream);
?>
]]>
</programlisting>
</example>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

146
reference/expect/ini.xml Normal file
View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: d4d5216e7a965ca194f6b1c9dee84cecab2674e5 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
<section xml:id="expect.configuration" xmlns="http://docbook.org/ns/docbook">
&reftitle.runtime;
&extension.runtime;
<para>
Para configurar a extensão expect, existem opções de configuração
no <link linkend="configuration.file">arquivo de configuração</link> &php.ini;.
<table>
<title>Expect &ConfigureOptions;</title>
<tgroup cols="4">
<thead>
<row>
<entry>&Name;</entry>
<entry>&Default;</entry>
<entry>&Changeable;</entry>
<entry>Registro de alterações</entry>
</row>
</thead>
<tbody xml:id="expect.configuration.list">
<row>
<entry><link linkend="ini.expect.timeout">expect.timeout</link></entry>
<entry>"10"</entry>
<entry><constant>INI_ALL</constant></entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.expect.loguser">expect.loguser</link></entry>
<entry>"1"</entry>
<entry><constant>INI_ALL</constant></entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.expect.logfile">expect.logfile</link></entry>
<entry>""</entry>
<entry><constant>INI_ALL</constant></entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.expect.match-max">expect.match_max</link></entry>
<entry>""</entry>
<entry><constant>INI_ALL</constant></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
&ini.php.constants;
</para>
&ini.descriptions.title;
<para>
<variablelist>
<varlistentry xml:id="ini.expect.timeout">
<term>
<parameter>expect.timeout</parameter>
<type>int</type>
</term>
<listitem>
<para>
O período de tempo limite para espera pelos dados, ao usar a
função <function>expect_expectl</function>.
</para>
<para>
Um valor "-1" desativa a ocorrência de um tempo limite.
</para>
<note>
<para>
Um valor "0" faz com que a função <function>expect_expectl</function>
retorne imediatamente.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.expect.loguser">
<term>
<parameter>expect.loguser</parameter>
<type>bool</type>
</term>
<listitem>
<para>
Se expect deve enviar qualquer saída do processo gerado para stdout.
Como os programas interativos normalmente refletem suas informações, isso geralmente é suficiente
para mostrar os dois lados da conversa.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.expect.logfile">
<term>
<parameter>expect.logfile</parameter>
<type>string</type>
</term>
<listitem>
<para>
Nome do arquivo onde será gravada a saída do processo gerado.
Se este arquivo não existir, ele será criado.
</para>
<note>
<para>
Se esta configuração não estiver vazia, a saída será escrita independentemente do
valor de <link linkend="ini.expect.loguser">expect.loguser</link>.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.expect.match-max">
<term>
<parameter>expect.match_max</parameter>
<type>int</type>
</term>
<listitem>
<para>
Altera o tamanho padrão (2000 bytes) do buffer usado para corresponder aos asteriscos
nos padrões.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 96c9d88bad9a7d7d44bfb7f26c226df7ee9ddf26 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
<reference xml:id="ref.expect" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>&Functions; de Expect</title>
&reference.expect.entities.functions;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: af4410a7e15898c3dbe83d6ea38246745ed9c6fb Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
<chapter xml:id="expect.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.setup;
<!-- {{{ Requirements -->
<section xml:id="expect.requirements">
&reftitle.required;
<para>
Este módulo usa as funções da biblioteca <link
xlink:href="&url.expect;">expect</link>.
Você precisa da versão libexpect &gt;= 5.43.0.
</para>
</section>
<!-- }}} -->
<!-- {{{ Installation -->
&reference.expect.configure;
<!-- }}} -->
<!-- {{{ Configuration -->
&reference.expect.ini;
<!-- }}} -->
<!-- {{{ Resources -->
<section xml:id="expect.resources">
&reftitle.resources;
<para>
<function>expect_popen</function> retorna um fluxo PTY aberto usado por
<function>expect_expectl</function>.
</para>
</section>
<!-- }}} -->
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->