run bash command in python and display on browser
Question: I have this simple python code:

    
    
    import os
    #os.system ("bash -c 'ls /home/'")
    script = "ls /home/user/"
    os.system(script)
    

How do I use PHP to display the output?


Answer: Not with HTML, but using PHP first you can output to HTML from a python script
using shell_exec e.g.

    
    
    <?php $output = shell_exec("python scriptName.py");
    echo '<p>'.$output.'<p>'; ?>
    

