PHP has a method to execute shell commands. It's called shell_exec
:
Execute a command using the command interpreter and return the
full output as a string.
Syntax
string shell_exec ( string $cmd )
Parameters
cmd
The command that will be executed.
Return values
The output of the executed command or NULL if an error occurs or the command produces no output.
Note:
This function can return NULL when an error occurs or when the program does not produce any output. It is not possible to detect the execution failures using this function. exec () should be used when necessary to access the exit code of the program.
Ejemplo #1 Un ejemplo de shell_exec()
<?php
$salida = shell_exec('ls -lart');
echo "<pre>$salida</pre>";
?>
Note: This function is disabled when PHP is running in mode
sure.
DEMO
<?php
$salida = shell_exec('uname -a');
echo $salida;
?>
Result
Linux lvps83-169-3-96.dedicated.hosteurope.de 4.4.0-042stab120.16
#1 SMP Tue Dec 13 20:58:28 MSK 2016 x86_64 x86_64 x86_64 GNU/Linux