我尝试将envsubst命令与作为选项传递给ogr2ogr的外部sql文件结合使用,但无法完全正常工作。
export STOP_NAME=Park;
ogr2ogr \
-f geojson \
/vsistdout/ \
stops.csv \
-dialect sqlite \
-sql envsubst < @stop_geo.sql其中,stop_geo.sql是:
SELECT *
FROM stops
WHERE stop_name = '$STOP_NAME'此错误显示为:
Warning 1: layer names ignored in combination with -sql.
ERROR 1: In ExecuteSQL(): sqlite3_prepare_v2(envsubst):
near "envsubst": syntax error有没有办法在ogr2ogr -sql命令选项中替换外部sql文件中的环境变量?
发布于 2020-06-21 10:30:24
envsubst命令需要包含在带引号的命令替换中(即"$()")。无需使用ogr2ogr sql documentation中提到的@语法,只需使用常见的<运算符读取即可。
export STOP_NAME=Park;
ogr2ogr \
-f geojson \
/vsistdout/ \
stops.csv \
-dialect sqlite \
-sql "$(envsubst < stop_geo.sql)"https://stackoverflow.com/questions/62430635
复制相似问题