I want to run a Python script "test.py" in my usr/local/bin directory, which will create a text file in the same directory and write some brief text to it.
This script is called by a Python subprocess in code that responds to a GET request to my web application, which resides at var/www
subprocess.Popen(["python", "usr/local/bin/test.py"])
The code runs without error, however the text file is not created. The code to to do this is straightforward:
myfile = open('test.txt','w+')
myfile.write("Write some text\n")
myfile.close()
I've tried passing options along with this including shell=True. As well, I've tried to use the interface provided by os.system(), also to no avail.
Just for testing purposes, I've given full permissions to all pertinent directories.
Running the test.py script via CLI works as intended, however not when called by the web application. What could be the issue?