I could obtain the output (in text file) of a python file by executing it on the command line, but was not able to obtain the output (in text file) by executing it using php exec(). What did i do wrongly?
this is my python file (example.py):
inputfile = open("input.txt",r)
data = inputfile.read()
inputfile.close()
outputfile = open("output.txt","w")
outputfile.write(str(data))
outputfile.write(str(data))
outputfile.close()
this is my php file (example2.php):
<?php
$string = "hello";
file_put_contents('input.txt', $string);
exec('python example.py');
$result = file_get_contents('output.txt');
i typed this on the commandline and it worked:
python example.py