system

(PHP 3, PHP 4 , PHP 5)

system -- Execute an external program and display the output

Popis

string system ( string command [, int &return_var] )

system() is just like the C version of the function in that it executes the given command and outputs the result. If a variable is provided as the second argument, then the return status code of the executed command will be written to this variable.

Varovanie

Ak povol�te, aby d�ta prich�dzaj�ce z u��vate�sk�ho vstupu boli posielan� tejto funkcii, potom by ste mali pou��va� escapeshellarg() alebo escapeshellcmd() pre uistenie sa, �e u��vatelia nem�u prelsti� syst�m na spracovanie �ubovo�n�ch pr�kazov.

Poznámka: Ak spust�te program vyu��vaj�ci t�to funkciu a chcete ho necha� be�a� na pozad�, mus�te sa uisti�, �i je v�stup tohto programu presmerovan� do s�boru alebo nejak�ho in�ho v�stupn�ho pr�du lebo inak PHP zostane vysie� pokia� sa spracovanie programu neskon��.

The system() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module.

Returns the last line of the command output on success, and FALSE on failure.

If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.

Príklad 1. system() example

<?php
echo '<pre>';

// Outputs all the result of shellcommand "ls", and returns
// the last output line into $last_line. Stores the return value
// of the shell command in $retval.
$last_line = system('ls', $retval);

// Printing additional info
echo '
</pre>
<hr />Last line of the output: '
. $last_line . '
<hr />Return value: '
. $retval;
?>

Poznámka: Ke� je safe mode povolen�, mo�ete iba sp�a� spustiteln� s�bory v r�mci safe_mode_exec_dir. Z praktick�ch d�vodov nie je moment�lne povolen� ma� .. komponenty v ceste k spustite�n�mu s�boru.

Varovanie

S povolen�m safe mode, sa so v�etk�mi slovami n�sleduj�cimi za po�iato�n�m re�azcom pr�kazu zaobch�dza ako s jedn�m argumentom. Teda, echo y | echo x sa st�va echo "y | echo x".

See also exec(), passthru(), popen(), escapeshellcmd(), pcntl_exec(), and the backtick operator.