<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.shell-exec.php',
    1 => 'shell_exec',
    2 => 'Ex&eacute;cute une commande via le Shell et retourne le r&eacute;sultat sous forme de cha&icirc;ne',
  ),
  'up' => 
  array (
    0 => 'ref.exec.php',
    1 => 'Fonctions sur l\'ex&eacute;cution de programmes externes',
  ),
  'prev' => 
  array (
    0 => 'function.proc-terminate.php',
    1 => 'proc_terminate',
  ),
  'next' => 
  array (
    0 => 'function.system.php',
    1 => 'system',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    '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">
   Exécute une commande via le Shell et retourne le résultat sous forme de chaîne
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.shell-exec-description">
  <h3 class="title">Description</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> est identique aux 
   <a href="language.operators.execution.php" class="link">guillemets obliques</a>.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Sur Windows, le tube sous-jacent est ouvert en mode texte, ce qui peut
    entraîner l&#039;échec de la fonction pour des sorties binaires. Il est recommandé d&#039;utiliser
    <span class="function"><a href="function.popen.php" class="function">popen()</a></span> dans de tels cas.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.shell-exec-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">command</code></dt>
     <dd>
      <p class="para">
       La commande à exécuter.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.shell-exec-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Une <a href="language.types.string.php" class="link">chaîne de caractères</a> contenant le résultat de la commande exécutée, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si le
   pipe ne peut pas être établi, ou <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> si une erreur survient ou
   si la commande ne produit aucune sortie.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Cette fonction peut retourner <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> lorsqu&#039;une erreur survient
    mais aussi lorsque le programme ne produit aucune sortie. Il n&#039;est pas possible
    de détecter les échecs d&#039;exécution en utilisant cette fonction. La fonction
    <span class="function"><a href="function.exec.php" class="function">exec()</a></span> doit être utilisée lorsqu&#039;on souhaite récupérer
    le code de sortie du programme.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 errors" id="refsect1-function.shell-exec-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Une erreur de niveau <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> est générée lorsque
   le pipe ne peut pas être établi.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.shell-exec-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <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">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.exec.php" class="function" rel="rdfs-seeAlso">exec()</a> - Ex&eacute;cute un programme externe</span></li>
    <li><span class="function"><a href="function.escapeshellcmd.php" class="function" rel="rdfs-seeAlso">escapeshellcmd()</a> - Prot&egrave;ge les caract&egrave;res sp&eacute;ciaux du Shell</span></li>
   </ul>
  </p>
 </div>

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