My php code is in htdocs/series/index.php. My python code location is /home/shivam/Desktop/hello.py I am running php using xampp in ubuntu. here is php code
<?php
$command = escapeshellcmd('/home/shivam/Desktop/hello.py');
$output = shell_exec($command);
echo $output;
?>
here is my python code
#!/usr/bin/env python
with open("/home/shivam/Desktop/solution.txt", "w") as myfile:
myfile.write("write text")
I am trying to run the python script using php to write to a file 'solution.txt'. When i write something myself to solution.txt and open it in read mode using python script via php then it works but when i try to write using above code ,i am unable to do so. One more thing, none of the code below the line "with open("/home/shivam/Desktop/solution.txt", "w") as myfile:" gets executed. I have tried the solution given in : enter link description here