我有一個簡單的cmd.php頁面來運行命令我輸入使用shell_exec()並顯示輸出。PHP - 從命令行調用.php文件不會產生輸出
- PHP 是運行的CGI
- 進入 「PHP -v」,大多數的命令只顯示 「內容類型:text/html的」,然後將當前網頁的HTML源。
但是,調用PHP帶有無效參數(的/ usr/bin中/ PHP的-z)示出了脈動熱管的使用:
用法:PHP [-q] [-h] [-s] [-v ] [-i] [-f] PHP [參數...]
等...
我添加了一組圖片來說明我的意思。
PHP不會產生預期的輸出
PHP -z -v顯示PHP的使用
任何想法?
編輯
cmd.php
<?php
if (isset ($_POST['submit'])) :
$response = shell_exec (escapeshellcmd (stripslashes ($_POST['cmd'])));
endif;
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
pre#response { border: 1px solid #e0e0e0; padding: .5em; }
</style>
<title>Command</title>
</head>
<body>
<form action="cmd.php" method="post">
<p><input type="text" name="cmd" id="cmd" value="<?php echo @htmlspecialchars (stripslashes ($_POST['cmd'])); ?>" size="50" />
<button type="submit" name="submit" id="submit" value="Submit">Submit</button>
</p>
</form>
<?php
if (isset ($response)) :
?>
<pre id="response"><?php
if (empty ($response)) :
echo 'No response.';
else :
echo htmlspecialchars ($response);
endif;
?></pre>
<?php
endif;
?>
</body>
</html>
預期產量是多少?我們可以看看** cmd.php **嗎? – Anax 2010-07-12 08:04:13
它應該顯示版本號...我發佈了源代碼。 – 2010-07-12 08:08:28
您的FCGI或CGI是否通過包裝腳本在chroot中運行? – Borealid 2010-07-12 08:22:05