简体   繁体   中英

php script to excute bash script and display results on webpage.

I'm trying to create very simple page that will look up email address in a logfile

I wrote a bash script (with complex awk and sed queries ) that accepts single argument (email address) and it will display the output as follows.

DATE                    email                      phone 
31/1/2013               test@example.com           1800-000-000

how can I go about creating a webpage that will only take an email address and a search button that will simply execute the bash script in the backend and display the output to the screen?

Thank you

 exec ("/path/to/script", $output); 

That will output result into the $output variable.

You can then create page.

<html>
<body>
<form action="index.php">
<input type="text" name="address" />
<input type="submit" value="Post!" />
</form>
</body>
</html>

In the index.php you can put such code:

<?php
     if ($_POST && $_POST['address']) {
          exec ("/path/to/script " . escapeshellarg($_POST['address']), $output); 
          echo $output;
     }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM