Search code examples
executableremote-serverserve

How to serve an executable


Let's say I have written a simple C program(language doesn't matter), compiled it and now I have the executable.

I was wondering if there is an easy way to serve the program on a webserver so for every connection to the server, the program is executed and the request.body will be treated as stdin and in the response.body the output will be sent back.


Solution

  • Assuming your Program name is: myprogram You can use:

    <?php    
        echo shell_exec("myprogram");
    ?>
    

    OR:

    <?php    
        echo shell_exec("/bin/bash myprogram");
    ?>
    

    In the above samples myprogram should be in current web-folder.

    If you have myprogam in other foler, then use FULL path.