2

I have a python script running a simple raster band analysis using GDAL library from Ubuntu. This runs perfectly when the script was executed from the command window under the same folder, but when I tried to run it from PHP it fails. Below is the error I got:

   Traceback (most recent call last):
  File "../SCRIPT/python/bandInfo.py", line 27, in <module>
    src_ds = gdal.Open( input_file )
  File "/usr/lib/python3/dist-packages/osgeo/gdal.py", line 2939, in Open
    return _gdal.Open(*args)
RuntimeError: No such file or directory

Seems like my directory is invalid, but the input path is indeed the correct path, is this something to do with the permission? But I do have ownership for all the folder and sub-folders... Anyone can help me out here? TIA!

MaxG
  • 199
  • 2
  • 12
  • check the permissions of the user running the webserver, those may differ from the ones needed for your script to read the whole paths. – LordNeo Mar 07 '17 at 14:52
  • Possible duplicate of [Running a Python script from PHP](http://stackoverflow.com/questions/19735250/running-a-python-script-from-php) – LordNeo Mar 07 '17 at 14:54
  • My python script does have the privilege: I used `chwon www-data:myusername *` for my entire SCRIPT folder – MaxG Mar 07 '17 at 15:18
  • i don't mean that. when you run a script from console, it's run on behalf of the user loged in, when you run it from a php/apache script, it's run on behalf of the user running the webserver. – LordNeo Mar 07 '17 at 16:47
  • nvm figured out the problem.. It is a permission issue for saving file, I tried to save the info of the raster band into a CSV file, didn't have the permission for the folder I'm trying to save the file to; I'm running the test locally, so the user permission is not the issue, but thanks for the note man anyways! Should be something I need to consider when I try to publish it! :) – MaxG Mar 07 '17 at 17:00

0 Answers0