0

I am a very new to web programming and perhaps this questions might seem to obvious. I have a form on the website and a button. When the button is pressed I want to call external program (Linux executable) which is located on the server, and pass all the text data from the filled form on the page to that program as arguments, and then get the output back to user. For ex: (./myprogram username userjob ...).

How can this be implemented? What language should I use? Javascript, PHP, Python?

Thank you

Tofig Hasanov
  • 3,303
  • 10
  • 51
  • 81
  • 1
    In addition to the answers below, take a look at http://stackoverflow.com/questions/732832/php-exec-vs-system-vs-passthru – jeremy Sep 05 '12 at 03:24

2 Answers2

2

You can simply use php for that:

<?php exec("./yourscript.sh");
Green Black
  • 5,037
  • 1
  • 17
  • 29
2

You can execute the program with the system call and add the arguments posted by the user to the end of it. It would look something like this:

$theResults = system(escapeshellcmd('./myProgram '.$_REQUEST['arguments']));
echo $theResult;

A full working example would be something like this:

<?php
if(!empty($_REQUEST['arguments'])){
    $results = system(escapeshellcmd('./myProgram '.$_REQUEST['arguments']));
}
?>

<html>
<head>
    <title></title>
</head>
<body>
    <?php
        if(!empty($results)){
            echo $results;
        }
    ?>
    <form method="post" action="">
        Your Arguments: <input type="text" name="arguments" value="" /><input type="submit" name="Submit" value="Submit" />
    </form>
</body>
</html>
Brett
  • 2,502
  • 19
  • 30