2341 发表于 2016-1-11 08:42:02

php页面传参给shell脚本

                      代码如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>MAC search</title>
</head>
<body align="middle" bgcolor="gray">
<h1><font size="20" face="Verdana" color="blue">MAC search</font></h1>
<form action="" method="post">
MAC:
<input type="text" name="mac" size="20"/>
<input type="submit" value="submit"/>
</form>
<?php
if(isset($_POST['mac'])&&$_POST['mac']!=''){
      $mac=$_POST['mac'];
$output = shell_exec("macsearch $mac");
echo "$output";
}
?>
</body>
</html>
分析如下:
    1.通过表单传入一个参数“mac”      
      <form action="" method="post">
      MAC:
      <input type="text" name="mac" size="20"/>
      <input type="submit" value="submit"/>
      </form>
    2.通过php传入参数并且运行shell脚本   
      <?php
      if(isset($_POST['mac'])&&$_POST['mac']!=''){
                $mac=$_POST['mac'];
      $output = shell_exec("macsearch $mac");
      echo "$output";
      }
      ?>



页: [1]
查看完整版本: php页面传参给shell脚本