0

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               [email protected]           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

1 Answer 1

1
 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;
     }
Sign up to request clarification or add additional context in comments.

6 Comments

where do I put "exec ("/path/to/script", $output); " in my index.php or in my bash script?
You should use escapeshellarg() around the post variable.
Well, I'm getting blank screen, where should I put escapeshellarg(), my php skills are really basic :(
@user1007727 Please, at first, please create page with such code "<?php echo 'test'; ?>" With such basic code you could ensured that webserver and php works fine, then if 'test' will be echoed I will provide you more help.
got blank screen with "test" seems like php is working fine :) any other next step / suggestions?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.