0

I'm a php learning beginner and I'm trying to run a python file with php command. I read Running a Python script from PHP and I did everything from the answers. But it didn't work for me.

Below is my php codes:

<?php 

$command = escapeshellcmd('test1.py');
$output = shell_exec($command);
echo $output;

?>

Below is my Python codes(I use Python 3.6):

#!/usr/bin/env python

f = open("test.txt", "a+")
f.write("hiya buddy!!\n")
f.close()
print("some output")

I did command chmod +x test1.py already. However, my test1.py didn't response anything.

Could someone help me with this problem? Any response will be appreciated!

Eunice TT
  • 49
  • 2
  • 7

0 Answers0