How to call python script from php script in raspberry pi? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to call python script from php script in raspberry pi?

I'm using python 2.7 in raspberry. I've created web server using apache in raspberry I want to call python script stored in pi using webpage created by php .

11th Feb 2017, 11:52 AM
Nikhil Bhambid
Nikhil Bhambid - avatar
3 Answers
0
<?php $output = ''; // If the first line of your python script //contains a Shebang, you can ommit // /path/to/python exec('/path/to/python /path/to/script.py', $output); // Script output will be stored in $output echo $output; // Displays the output of your python script ?>
11th Feb 2017, 12:00 PM
qobus
0
I will try this. thank you. what if I want to give command to run python script to button created on php?
11th Feb 2017, 12:40 PM
Nikhil Bhambid
Nikhil Bhambid - avatar
0
it's not working.
11th Feb 2017, 1:32 PM
Nikhil Bhambid
Nikhil Bhambid - avatar