#!/bin/csh -f

if($1 == "-h" || $1 == "" || $2 == "" || $#argv != 2) then
 echo " "
 echo "Usage:   "
 echo  "  >> import_geo_from_table fromtablename tablenameto"
 echo  "     loads <tablenamefrom> into <tablenameto>"
 echo " "
 exit 0
endif

set tablefrom = $1
set tableto   = $2


rm -f tmp.txt
echo  "use user_geometry;"                                 > tmp.txt
echo  "insert into $tableto select * from $tablefrom ;"   >> tmp.txt 

echo "Importing geomtry from $tablefrom into $tableto Are you sure? y/n"
set confirm = $<
if($confirm == "y") then
  mysql -h $GEMC_HOST -u $GEMC_USER                     < tmp.txt 
  echo Done.
endif
rm -f tmp.txt
