MaddMatt
May 13th, 2010, 12:32 PM
Hi All,
I need to batch import shapefiles into a geospatial database I just set up and I wrote this script to automate the process:
#! /bin/bash
DIR="/searchdirectory/"
SCHEMA="Basemap"
DBNAME="GIS_Database"
find $DIR -nowarn -name *.shp > /home/user/$SCHEMA.t
cat /home/user/$SCHEMA.t | while read line
do
TABLENAME=`echo "${line}" | sed 's/.shp//' | rev | cut -d"/" | rev`
echo "shp2pgsql -s 32629 ${line} $SCHEMA.$TABLENAME | psql -d $DBNAME" >> /home/user/testoutput.t
done
but the script is getting hung up with the cut command:
cut: you must specify a list of bytes, characters, or fields
Try `cut --help' for more information.
I've tried re-writing it a few different ways, but no luck. There is text in the $SCHEMA.t input file, so I think it has to do with the quotation marks in the echo statement. Anyone see my error? Thanks in advance,
Cheers
m
I need to batch import shapefiles into a geospatial database I just set up and I wrote this script to automate the process:
#! /bin/bash
DIR="/searchdirectory/"
SCHEMA="Basemap"
DBNAME="GIS_Database"
find $DIR -nowarn -name *.shp > /home/user/$SCHEMA.t
cat /home/user/$SCHEMA.t | while read line
do
TABLENAME=`echo "${line}" | sed 's/.shp//' | rev | cut -d"/" | rev`
echo "shp2pgsql -s 32629 ${line} $SCHEMA.$TABLENAME | psql -d $DBNAME" >> /home/user/testoutput.t
done
but the script is getting hung up with the cut command:
cut: you must specify a list of bytes, characters, or fields
Try `cut --help' for more information.
I've tried re-writing it a few different ways, but no luck. There is text in the $SCHEMA.t input file, so I think it has to do with the quotation marks in the echo statement. Anyone see my error? Thanks in advance,
Cheers
m