0

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')
tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Possible duplicate of [here-document delimited by end-of-file](http://stackoverflow.com/questions/18660798/here-document-delimited-by-end-of-file) – tripleee Apr 04 '16 at 16:02

1 Answers1

1

The line SSHSQLTEXT) needs to be replaced by two lines, such as:

SSHSQLTEXT
)

The heredoc name needs to match the entire line at the end.

Phylogenesis
  • 7,775
  • 19
  • 27