获得内容,然后运行你的脚本,然后获取返回内容.         $cmd = " test.sh " . $_POST['ip'];
         if ($result = popen($cmd, "r"))
         {
                while (!feof($result))
                {
                   $line = fgets($result, 1024);
                   $strContent .= $line;
                   //if ($pre) $line = replaceEntities($line, $this->repConfig);
                }
            pclose($result);
        }
        //显示脚本执行结果
        echo $strContent;

解决方案 »

  1.   


    谢谢Jakey兄,俺对php一窍不通,现在想通过php做一个web工具供大家使用。请问文本框和按钮这些地方怎么写?怎么跟上面的内容连接起来使用。再次感谢!
      

  2.   

    做个form提交过来就可以了.
    <form name="form1" method="post" action="xxx.php"> 
    <input type='text' name='ip' value=""/>
    <input name="submit" type="submit"  value="提交"/>
    </form> xxx.php<?php
      if($_POST['submit'] != "")
      {
             $cmd = " test.sh " . $_POST['ip'];
             if ($result = popen($cmd, "r"))
             {
                    while (!feof($result))
                    {
                       $line = fgets($result, 1024);
                       $strContent .= $line;
                       //if ($pre) $line = replaceEntities($line, $this->repConfig);
                    }
                pclose($result);
            }
            //显示脚本执行结果
            echo $strContent;
       }
      

  3.   

    保存上述代码为1.php(若正确)<input type="button" onclick="iframe1.src='1.php'><iframe style="display:hidden" name="iframe1">