[postgis-users] shp2pgsql in a bash script question

Morin, Marc-André Marc-Andre.Morin at dfo-mpo.gc.ca
Mon May 9 05:13:38 PDT 2011


The easiest way is to lauch pgAdmin and connect to the server.  At the first time, a little window will be prompted asking you password for the user postgres, and once you will have entered this password, just check the option "Store password"...  And you will never be asked to enter this password anymore when you will launch your batch file.
 
Hope this help,
 
Marc-André

________________________________

De : postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] De la part de Carl Anderson
Envoyé : 7 mai 2011 17:43
À : PostGIS Users Discussion
Objet : Re: [postgis-users] shp2pgsql in a bash script question


You would only have to enter the password once if you changed your script like this. 

#!/bin/bash


(  
for dir in BG CD CONCITY COUNTY COUSUB LINEARWATER PRIMARYROADS PRISECROADS RAILS ROADS STATE SUBMCD TABBLOCK
do
        ldir="$(echo ${dir} | tr 'A-Z' 'a-z')" >> download.log
shp2pgsql -s 4326 -p ${dir}/tl_2010_01_${ldir}10 public.${ldir}


done  )  | psql -h localhost -d geotest -U uname -W  >> load.log 




C.


On Sat, May 7, 2011 at 4:12 PM, Dheeraj Chand <dheeraj at dheerajchand.com> wrote:



	:I have the world's dumbest question today. I am running a bash script that goes through several directories (and each of their several subdirectories) of shapefiles to run shp2pgsql and put them into the correct PSQL schema and table.  I'd like to be able to set it and forget it, so to speak, but each time, the shell is prompting me for the user's password. Is there a way to hardcode the password in?
	[4:06pm] 
	
	#!/bin/bash
	for dir in BG CD CONCITY COUNTY COUSUB LINEARWATER PRIMARYROADS PRISECROADS RAILS ROADS STATE SUBMCD TABBLOCK
	do
	        ldir="$(echo ${dir} | tr 'A-Z' 'a-z')" >> download.log
	shp2pgsql -s 4326 -p ${dir}/tl_2010_01_${ldir}10 public.${ldir} | psql -h localhost -d geotest -U uname -W pass >> load.log
	
	
	done
	[4:07pm]
	Here is the script: http://pastebin.com/prWLzEtk:

	_______________________________________________
	postgis-users mailing list
	postgis-users at postgis.refractions.net
	http://postgis.refractions.net/mailman/listinfo/postgis-users
	
	




-- 
Carl Anderson, GISP
 
canderson at spatialfocus.com
carl.anderson at vadose.org


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110509/2154becc/attachment.html>


More information about the postgis-users mailing list