<?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 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.system.php',
    1 => 'system',
    2 => 'Esegue un programma esterno e mostra l\'output',
  ),
  'up' => 
  array (
    0 => 'ref.exec.php',
    1 => 'Program execution Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.shell-exec.php',
    1 => 'shell_exec',
  ),
  'next' => 
  array (
    0 => 'book.parallel.php',
    1 => 'parallel',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/exec/functions/system.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.system" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">system</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">system</span> &mdash; <span class="dc-title">Esegue un programma esterno e mostra l&#039;output</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.system-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>system</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="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter reference">&$return_var</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>system()</strong></span> è proprio come la versione C della
   funzione in quanto esegue il comando
   <code class="parameter">command</code> dato e restituisce il risultato.
  </p>
  <p class="para">
   La chiamata a <span class="function"><strong>system()</strong></span> prova anche a svuotare
   automaticamente il buffer di output del web server dopo ogni linea di output se
   PHP è in esecuzione come modulo server.
  </p>
  <p class="para">
   Se è necessario eseguire un comando ottenendo direttamente tutti
   i dati restituiti dallo stesso senza alcuna interferenza, usare la
   funzione <span class="function"><a href="function.passthru.php" class="function">passthru()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.system-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">command</code></dt>
     <dd>
      <p class="para">
       Il comando che verrà eseguito.
      </p>
     </dd>
    
    
     <dt><code class="parameter">return_var</code></dt>
     <dd>
      <p class="para">
       Se viene passato l&#039;argomento <code class="parameter">return_var</code> allora lo
       stato di ritorno del comando eseguito verrà scritto in questa
       variabile.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.system-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Restituisce l&#039;ultima riga dell&#039;output del comando in caso di successo e <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
   in caso di fallimento.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.system-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Esempio di <span class="function"><strong>system()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'&lt;pre&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Mette nell'output tutti i risultati del comando da shell "ls", e restituisce<br />// l'ultima linea di output nella $last_line. Memorizza il valore restituito<br />// del comando da shell in $retval.<br /></span><span style="color: #0000BB">$last_line </span><span style="color: #007700">= </span><span style="color: #0000BB">system</span><span style="color: #007700">(</span><span style="color: #DD0000">'ls'</span><span style="color: #007700">, </span><span style="color: #0000BB">$retval</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Stampa informazioni aggiuntive<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'<br />&lt;/pre&gt;<br />&lt;hr /&gt;L\'ultima linea dell\'output: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$last_line </span><span style="color: #007700">. </span><span style="color: #DD0000">'<br />&lt;hr /&gt;Valore di ritorno: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$retval</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.system-notes">
  <h3 class="title">Note</h3>
  <div class="warning"><strong class="warning">Avviso</strong><p class="para">Se si permette di passare a questa funzione i dati
provenineti dagli input utente, si dovrebbe utilizzare la funzione
<span class="function"><a href="function.escapeshellarg.php" class="function">escapeshellarg()</a></span> oppure <span class="function"><a href="function.escapeshellcmd.php" class="function">escapeshellcmd()</a></span>
in modo da essere sicuri che gli utenti non possano compromettere il sistema eseguendo 
comandi arbitrari.</p></div>
  <blockquote class="note"><p><strong class="note">Nota</strong>: <p class="para">Se si avvia un programma con questa funzione
e si vuole lasciarlo in esecuzione in background, ci si deve accertare che
l&#039;output del programma venga redirezionato verso un file o qualche altro stream di output, altrimenti
PHP si fermerà finché l&#039;esecuzione del programma sarà terminata.</p></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.system-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.exec.php" class="function" rel="rdfs-seeAlso">exec()</a> - Esegue un programma esterno</span></li>
    <li><span class="function"><a href="function.passthru.php" class="function" rel="rdfs-seeAlso">passthru()</a> - Esegue un programma esterno e mostra l'output non elaborato</span></li>
    <li><span class="function"><a href="function.popen.php" class="function" rel="rdfs-seeAlso">popen()</a> - Apre un puntatore ad un file di processo</span></li>
    <li><span class="function"><a href="function.escapeshellcmd.php" class="function" rel="rdfs-seeAlso">escapeshellcmd()</a> - Elude i metacaratteri della shell</span></li>
    <li><span class="function"><a href="function.pcntl-exec.php" class="function" rel="rdfs-seeAlso">pcntl_exec()</a> - Executes specified program in current process space</span></li>
    <li><a href="language.operators.execution.php" class="link">l&#039;operatore backtick</a></li>
   </ul>
  </p>
 </div>

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