Quantcast
Channel: Running a Python script from PHP - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Answer by SMshrimant for Running a Python script from PHP

$
0
0

The above methods seem to be complex. Use my method as a reference.

I have these two files:

  • run.php

  • mkdir.py

Here, I've created an HTML page which contains a GO button. Whenever you press this button a new folder will be created in directory whose path you have mentioned.

run.php

<html><body><head><title>     run</title></head><form method="post"><input type="submit" value="GO" name="GO"></form></body></html><?phpif(isset($_POST['GO'])){shell_exec("python /var/www/html/lab/mkdir.py");echo"success";}?>

mkdir.py

#!/usr/bin/env python    import os    os.makedirs("thisfolder");

Viewing all articles
Browse latest Browse all 12

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>