Hello,
I am executing a python script from django as described below.
def executeScript(request):
'''
View to execute script from web interface
'''
print "Execute script view called"
basepath = os.path.dirname(os.path.abspath(__file__))
filepath = basepath + os.path.sep + "script" + os.path.sep + "dataintegrator.py"
argpath = basepath + os.path.sep + "script" + os.path.sep + "urls.txt"
print "FilePath : " + filepath
print "ArgPath : " + argpath
test = subprocess.call(["python", filepath, argpath])
print "###########Result of execution is : " + str(test)
return HttpResponseRedirect("webadmin")
Here in above code, dataintegrator.py is a script that I am executing from django web. Now code in a script opens a file called "maps.txt" which is also in same directory as dataintegrator.py. When I execute script from command line it can read file but execution from web interface gives exception.