Jump to content

How Do I Run Python Script Using Exec Command In Php?


valkyrion123

Recommended Posts

You can't since we disabled exec.

 

The closest I can think of is to write the python script as if it were for a website, then file_get_contents() the script through the web server from php. The output of your python script will end up in the return variable of the file get contents call for you to use in php.

Link to comment
Share on other sites

You can't since we disabled exec. The closest I can think of is to write the python script as if it were for a website, then file_get_contents() the script through the web server from php. The output of your python script will end up in the return variable of the file get contents call for you to use in php.

 

hmm since my scripts is only triggered by some action and also need an input for it, with that method, how did i pass the input to the script?

 

thanks

Link to comment
Share on other sites

If the python script is written for a web server, it can be made to accept data from POST and GET requests. You'd make a form in HTML to enter the required data, the submitted data is passed via POST to the script, script runs it and returns output. I don't know how to handle POST data in Python though (I'm a PHP programmer).

 

You can likely eliminate the PHP component entirely if you're insistent on using Python. Do you have good reason (other than not wanting to rewrite your code) to use two languages?

 

If it were me, I'd just rewrite the Python tasks in PHP and discard the python components...

Link to comment
Share on other sites

If the python script is written for a web server, it can be made to accept data from POST and GET requests. You'd make a form in HTML to enter the required data, the submitted data is passed via POST to the script, script runs it and returns output. I don't know how to handle POST data in Python though (I'm a PHP programmer). You can likely eliminate the PHP component entirely if you're insistent on using Python. Do you have good reason (other than not wanting to rewrite your code) to use two languages? If it were me, I'd just rewrite the Python tasks in PHP and discard the python components...

 

well my python script do web scraping with form input handling and i don't know how to do that in PHP, also i got another one for image recognition and python is easier also faster and that is why i keep using this script.

 

but since you said python can be made into POST request, i think i can learn one..

 

Thanks for your help

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...