简体   繁体   中英

Linux variable to get data using ssh gives warning: here-document at line 95 delimited by end-of-file (wanted `SSHSQLTEXT')

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')

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM