cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello,

i want to use hdbsql in a shell script, to run a query for checking database backups. Unfortunately i am only able to login with hdbuserstorekey in my script after that the select statement does not work (select "command not found")

SAPSTRING=$(find /usr/sap/ccms -maxdepth 2 -type d -name sapccmsr | head -n 1 | cut -c 15-17)
HDBSTRING=$(/usr/bin/cat /usr/sap/"$SAPSTRING"/SYS/profile/DEFAULT.PFL | grep dbs/hdb/dbname | awk {' print$3'})
echo "HDB System ID ----------> " $HDBSTRING
declare -l HDBSIDADM
HDBSIDADM=$HDBSTRING'adm'

HDBBACKUPTEST=$(sudo su - "$HDBSIDADM" -c 'hdbsql -c ";" "\c -U HDBUSERSTOREKEY ";" select * from "SYS"."M_BACKUP_CATALOG" " ' )

 

this results in

-bash: select * from SYS.M_BACKUP_CATALOG : command not found

 

seems like that after the successful connect with hdbuserstorekey, it closes the connection and so the select command is not known.

any ideas?

 

thanks in advance

 

 

0 Likes
View Entire Topic
CharlesFeng
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi @qwertie ,

In the past, I encountered similar errors. I resolved them by placing the hdbsql commands in a file and then calling it from the shell script.
I suggest you try this approach.

Best regards,
Charles