Running a Python script from PHP

后端 未结 9 2212
鱼传尺愫
鱼传尺愫 2020-11-22 00:57

I\'m trying to run a Python script from PHP using the following command:

exec(\'/usr/bin/python2.7 /srv/http/assets/py/switch.py arg1 arg2\');

H

9条回答
  •  没有蜡笔的小新
    2020-11-22 01:30

    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

    
     
      
       
         run
       
      
    
       

    mkdir.py

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

提交回复
热议问题