0
我在树莓派上有一个Apache服务器。我有一个基本的程序,用户在一个html表单框中输入一个字符串。点击submit将条目发送到一个php文件,然后调用一个shell脚本,并将该条目作为提示传递。如果你看看下面的php,它有一个用户输入的变量,它调用shell文件main.sh.我怎样才能提供shell程序这个变量作为输入。我看过proc_open,但一直没有能够得到它的工作。感谢 的index.html:PHP执行shell脚本并提供输入提示
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="script.php" method="post" enctype="multipart/form-data">
Address: <input type="text" name="Address" value=""><br>
<input type="submit" value="Upload" name="submit">
</form>
</body>
</html>
的script.php:
<?php
if(isset($_POST["submit"])) {
if($_POST['Address'] != "")
{
$entry = $_POST['Address'];
$output = shell_exec ("./main.sh");
echo $output;
}
}
?>
最后的shell文件:main.sh:
echo -n "Do you like pie (y/n)? "
read answer
if echo "$answer" | grep -iq "^y" ;then
echo Yes
else
echo No
fi
好以后我会尝试一下,谢谢 – figbar
我看着你附加的链接,和它的工作,我只是忘了让我的PHP变种逃生壳ARG当我之前测试过这个方法。谢谢, – figbar