Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have this bash script (loadShapefiles.sh) to load multiple shapefiles at a time. The script and the shapefiles are stored in the same directory. When I run the bash file with the command of bash loadShapefiles.sh, I have this error message: syntax error near unexpected token '$'do\r'' I appreciate your suggestions to fix this problem!

for f in *.shp
do
    shp2pgsql -d -I -s 2913 $f rlis.`basename $f .shp` > `basename $f .shp`.sql  
done    

for f in *.sql  
do  
    psql -d portland -f $f  
done
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

I think you are missing some semicolons. Bash isn't python :-)

Does something like:

for f in *.shp; do shp2pgsql -d -I -s 2913 $f rlis.`basename $f.shp` > `basename $f.shp`.sql; done
for f in *.sql; do psql -d portland -f $f; done

work for you?

share|improve this answer
    
I still have a similar error message: syntax error near unexpected token `$'\r'' –  POTENZA Dec 3 '12 at 21:07
    
can you just run it on the command line? One line at a time? Are you definitely running it on bash and not some other shell? Can you put-n-paste the command line and error message? –  BradHards Dec 3 '12 at 21:20
    
It worked with one line at a time. I am a beginner on bash. Thank you very much for your help! –  POTENZA Dec 3 '12 at 21:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.