I need to get value from Vertica DB and assign it to variable in shell for further use. Vertica DB resides in separate linux server. I am using a script below to fetch data. It works and assigns value to linux variable as well. But I am getting warning. Removing single quotes from 'SSHSQLTEXT' makes the code block non-functional.
Code:
execute_command="SELECT SCHEMA_ID FROM V_CATALOG.SCHEMATA WHERE SCHEMA_NAME = '$v_schema_name'; "
retVal=$(ssh $o_pem_key_string $v_server_user@$v_server_name ssh_v_db_name=$v_db_name ssh_v_schema_name=$v_schema_name ssh_v_schema_pwd=$v_schema_pwd ssh_execute_command=\""$execute_command"\" \'bash -s\' <<'SSHSQLTEXT'
/opt/vertica/bin/vsql -d $ssh_v_db_name -U $ssh_v_schema_name -w $ssh_v_schema_pwd -c "$ssh_execute_command"
SSHSQLTEXT)
has_log_table_val=($retVal)
export v_schema_id=${has_log_table_val[2]}
echo $v_schema_id
Warning Message:
./testsample.sh: line 97: warning: here-document at line 95 delimited by end-of-file (wanted `SSHSQLTEXT')