[GIS] OSGeo4W does not add bin directory to Windows PATH

osgeo4wshp2pgsql

I am trying to run the following shp2pgsql cmd using the OSGeo4W shell:

shp2pgsql -s 4269 -g geom_4269 -I -W "latin1"
"tl_2012_states" staging.tl_2012_states | 
psql -h localhost -p 5432 -d dvdtwo -U postgres

but I am getting the following error:

'shp2pgsql' is not recognized as an internal or external command, operable program or batch file

I have tried updating the environment variable path to include the PostgreSQL\9.5\bin, but that hasn't worked.

What should I try next, or what do you think my problem is?

I am using, PosgreSQL 9.5, QGIS 2.18.5, PostGIS 2.0

Best Answer

is not recognized as an internal or external command, operable program or batch file

OSGeo4W specifically has closed the ticket to add this to the system path. The DLLS may conflict with other system DLLs and cause problems.

You need to statically point to the absolute location of shp2pgsql, in the case of OSGeo4W and with your example, I believe it's

C:\OSGeo4W\bin\shp2pgsql -s 4269 -g geom_4269 -I -W "latin1" "tl_2012_states" staging.tl_2012_states | psql -h localhost -p 5432 -d dvdtwo -U postgres

I got the path from the docs on the directory structure. I have no idea if the docs are correct though.