I am trying to execute pgsql2shp for a remote postgres db using batch file using the below code
for /f %%i in ('psql -U ihadmin -d ih_gis_production -h <xxxxx> -c "select f_table_name from geometry_columns where f_table_schema='mls_dataset';"') do (
set file_name=D:/Processing/DB_Dump/airdrie/mls_datatset/%%i
set table_name=%%i
pgsql2shp -h <xxxxx> -f %file_name% -u ihadmin -P xxxxx ih_gis_production mls_dataset.%table_name%
)
This will get table names from from the above select query and loop and export those tables to shapefile. When i run this from batch file, i am seeing pgsql2shp help options in command prompt. Any correct way to call pgsql2shp via batch ?