我正在尝试创建一个非常简单的页面,它将在日志文件中查找电子邮件地址
我编写了一个接受单个参数(电子邮件地址)的 bash 脚本(带有复杂的 awk 和 sed 查询),它将显示如下输出。
DATE email phone
31/1/2013 test@example.com 1800-000-000
我怎样才能创建一个只包含一个电子邮件地址和一个搜索按钮的网页,该按钮将简单地在后端执行 bash 脚本并将输出显示到屏幕上?
谢谢
最佳答案
exec ("/path/to/script", $output);
这会将结果输出到 $output 变量中。
然后您可以创建页面。
<html>
<body>
<form action="index.php">
<input type="text" name="address" />
<input type="submit" value="Post!" />
</form>
</body>
</html>
在index.php中你可以放这样的代码:
<?php
if ($_POST && $_POST['address']) {
exec ("/path/to/script " . escapeshellarg($_POST['address']), $output);
echo $output;
}
关于php 脚本来执行 bash 脚本并在网页上显示结果。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14630977/