
removido
(usa Nenhuma)
Enviado em 24/08/2011 - 11:02h
#!/bin/bash
# package: O nome do sistema
# file: nome_do_script.sh
# Descrisção básica.
#
# date: 2011-08-24 23:58 (GMT -03:00)
# + Modularização em funções - procedimentos ampliado
# version: 1.2a
# autor: Paulo Riceli (./.ronin) [
http://sekysu.blogspot.com ]
#
# since : 2011-08-03 23:58 (GMT -03:00)
# version: 1.0b
# autor: autor [ link ]
#
# charset: UTF-8
# end line: Linux
# more: onde posso achar informações adicionais sobre este código
# license:
function _getMessage()
{
MSG='
O campo digitado não existe!
Tente de novo ou prima Ctrl + C para sair.
'
echo $MSG
}
function _setParam()
{
if [ -n $1 ]
then
echo 'Parametro faltando'
exit 1
fi
}
function _getData()
{
NOME_MUNI=$( _setParam $1 )
NOME_PASSEIO=$( _setParam $2 )
CAMPO_RUA=$( _setParam $3 )
NOME_RUA=$( _setParam $4 )
psql -d $NOME_MUNI -c "
UPDATE $NOME_PASSEIO SET rua = (
SELECT $CAMPO_RUA FROM $NOME_RUA ORDER BY ST_Distance(
Line_Interpolate_Point_Alter( $NOME_RUA.wkb_geometry, 0.5 ),
$NOME_PASSEIO.wkb_geometry )
ASC LIMIT 1 )
"
}
function _getErros()
{
CAMPO_RUA=$1
MSG_ERR='does not exist'
ERR='relation "$CAMPO_RUA" does not exist'
GET_RST=$( echo $ERR | cut -d ' ' -f 2- )
if [ "$GET_RST" != "$MSG_ERR" ]
then
_getMessage
exit 1
fi
}
MSG='Digite bla bla bla'
while : ; do
echo $MSG
read CAMPO_RUA
_getData $CAMPO_RUA $2 $3 $4 &&
break ||
_getErrors
done
exit
Boa Sorte!