获得内容,然后运行你的脚本,然后获取返回内容. $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;
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;
谢谢Jakey兄,俺对php一窍不通,现在想通过php做一个web工具供大家使用。请问文本框和按钮这些地方怎么写?怎么跟上面的内容连接起来使用。再次感谢!
<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;
}