代码如下:<?php
$cmd_prog='e:\web\php_asp\file\cmd.exe';
if(!is_file($cmd_prog))
{
echo "Can't find $cmd_prog<br>";
exit;
}
?>
<html>
<head>
<title>cmd example</title>
</head>
<body>
<?php
if($REQUEST_METHOD='POST')
{
if($aFile=popen("$cmd_prog $cmd","r"))
{
while(!feof($aFile))
{
$aLine=fgets($aFile,1024);
print("$aLine<br>");
}
pclose($aFile);
}
else
{
echo "unable to execute cmd.exe";
}
print("hr");
}
?>
<form action="<?php echo PHP_SELF ?>" method="post">
cmd:<input type="text" name="cmd">
<input type="submit" name=Submit" value="submit">
</form>
</body>
</html>
$cmd_prog='e:\web\php_asp\file\cmd.exe';
if(!is_file($cmd_prog))
{
echo "Can't find $cmd_prog<br>";
exit;
}
?>
<html>
<head>
<title>cmd example</title>
</head>
<body>
<?php
if($REQUEST_METHOD='POST')
{
if($aFile=popen("$cmd_prog $cmd","r"))
{
while(!feof($aFile))
{
$aLine=fgets($aFile,1024);
print("$aLine<br>");
}
pclose($aFile);
}
else
{
echo "unable to execute cmd.exe";
}
print("hr");
}
?>
<form action="<?php echo PHP_SELF ?>" method="post">
cmd:<input type="text" name="cmd">
<input type="submit" name=Submit" value="submit">
</form>
</body>
</html>
第21行代码: $aLine=fgets($aFile,1024);
Notice: Undefined variable: cmd in E:\web\php_asp\file\cmd.php on line 17
Microsoft Windows XP [版本 5.1.2600] 2、在文档头部加入set_time_limit(0);将不会产生如下错误:
Fatal error: Maximum execution time of 30 seconds exceeded in E:\web\php_asp\file\cmd.php on line 21