<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.exec.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.shell-exec.php',
    1 => 'shell_exec',
    2 => 'Ejecuta un comando a trav&eacute;s del Shell y devuelve el resultado en forma de string',
  ),
  'up' => 
  array (
    0 => 'ref.exec.php',
    1 => 'Funciones de ejecuci&oacute;n de programas',
  ),
  'prev' => 
  array (
    0 => 'function.proc-terminate.php',
    1 => 'proc_terminate',
  ),
  'next' => 
  array (
    0 => 'function.system.php',
    1 => 'system',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/exec/functions/shell-exec.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.shell-exec" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">shell_exec</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">shell_exec</span> &mdash; <span class="dc-title">
   Ejecuta un comando a través del Shell y devuelve el resultado en forma de string
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.shell-exec-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>shell_exec</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$command</code></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>shell_exec()</strong></span> es idéntico a los
   <a href="language.operators.execution.php" class="link">backticks</a>.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    En Windows, el tubo subyacente se abre en modo texto lo que puede causar que
    la función falle para salidas binarias. Considerar el uso de
    <span class="function"><a href="function.popen.php" class="function">popen()</a></span> para tales casos.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.shell-exec-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">command</code></dt>
     <dd>
      <p class="para">
       El comando a ejecutar.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.shell-exec-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   Un <span class="type"><a href="language.types.string.php" class="type string">string</a></span> que contiene el resultado del comando ejecutado, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si el
   pipe no puede ser establecido, o <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> si ocurre un error
   o si el comando no produce salida.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Esta función puede devolver <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> cuando ocurre un error
    pero también cuando el programa no produce salida. No es posible
    detectar fallos de ejecución utilizando esta función. La función
    <span class="function"><a href="function.exec.php" class="function">exec()</a></span> debe ser utilizada cuando se desea recuperar
    el código de salida del programa.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 errors" id="refsect1-function.shell-exec-errors">
  <h3 class="title">Errores/Excepciones</h3>
  <p class="para">
   Un error de nivel <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> es generado cuando el
   pipe no puede ser establecido.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.shell-exec-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Ejemplo con <span class="function"><strong>shell_exec()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$output </span><span style="color: #007700">= </span><span style="color: #0000BB">shell_exec</span><span style="color: #007700">(</span><span style="color: #DD0000">'ls -lart'</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"&lt;pre&gt;</span><span style="color: #0000BB">$output</span><span style="color: #DD0000">&lt;/pre&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.shell-exec-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.exec.php" class="function" rel="rdfs-seeAlso">exec()</a> - Ejecuta un programa externo</span></li>
    <li><span class="function"><a href="function.escapeshellcmd.php" class="function" rel="rdfs-seeAlso">escapeshellcmd()</a> - Protege los caracteres especiales del Shell</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>