Double quotes in run() function

Hi,
I want to execute an external tool out of Julia using the run() function:

run(`gdal_translate -of GTiff HDF4_EOS:EOS_GRID:"$(hdf_path)":MODIS_Grid_16DAY_500m_VI:"500m 16 days NDVI" $gtiff_path`)

which produces an error:

run(`gdal_translate -of GTiff HDF4_EOS:EOS_GRID:"$(hdf_path)":MODIS_Grid_16DAY_500m_VI:"500m 16 days NDVI" $gtiff_path`)
ERROR 4: HDF4_EOS:EOS_GRID:/home/MYD13A1.A2020137.h35v09.006.2020154001932.hdf:MODIS_Grid_16DAY_500m_VI:500m 16 days NDVI: No such file or directory
ERROR: failed process: Process(`gdal_translate -of GTiff 'HDF4_EOS:EOS_GRID:/home/MYD13A1.A2020137.h35v09.006.2020154001932.hdf:MODIS_Grid_16DAY_500m_VI:500m 16 days NDVI' /home/MYD13A1.A2020137.h35v09.006.2020154001932.tif`, ProcessExited(1)) [1]

As can be seen, the command includes some double quotes. If I run the command
gdal_translate -of GTiff 'HDF4_EOS:EOS_GRID:/home/MYD13A1.A2020137.h35v09.006.2020154001932.hdf:MODIS_Grid_16DAY_500m_VI:500m 16 days NDVI' /home/MYD13A1.A2020137.h35v09.006.2020154001932.tif
from the error message in the terminal it works well. Is that error related to the double quotes?

Have you tried running that exact command literally from Julia? Seems unlikely to be related to the quotes, they only affect the parsing of the command, not what’s run.

Yes, you are right! It was an issue related to the environment where the (gdal_translate) tool is installed. It works well using the right environment.

1 Like