I have the following function :GetHostName () {NODE01_CHECK=`cat /etc/hosts | grep -w node01 | awk '{print $1}'`NODE02_CHECK=`cat /etc/hosts | grep -w node02 | awk '{print $1}'`IS_NODE1=`ifconfig -a | grep -w $NODE01_CHECK`IS_NODE2=`ifconfig -a | grep -w $NODE02_CHECK`if [[ ! -z $IS_NODE1 ]]; then    echo This is NODE 1fiif [[ ! -z $IS_NODE2 ]]; then    echo This is Node 2fi}This script will identify if a certain ip is configured on one of the two nodes belonging to a cluster. This works fine locally, but I need to run it remotely from a server that only knows of the VIP of the cluster. The goal is to transfer some files to both nodes.So when I run :scp -r /tmp/files CLUST_VIP ssh CLUST_VIP <<EOF        NODE01_CHECK=`cat /etc/hosts | grep -w node01 | awk '{print $1}'`        NODE02_CHECK=`cat /etc/hosts | grep -w node02 | awk '{print $1}'`        IS_NODE1=`ifconfig -a | grep -w $NODE01_CHECK`        IS_NODE2=`ifconfig -a | grep -w $NODE02_CHECK`        if [[ ! -z $IS_NODE1 ]]; then               scp -r /tmp/files node02        fi        if [[ ! -z $IS_NODE2 ]]; then               scp -r /tmp/files node01        fi  EOFHowever, now while running the same commands in a ssh block, I get the following messages :Usage: grep [OPTION]... PATTERN [FILE]...Try 'grep --help' for more information.Usage: grep [OPTION]... PATTERN [FILE]...Try 'grep --help' for more information.Pseudo-terminal will not be allocated because stdin is not a terminal.I have also tried using ssh -t and that removed the above errors regarding grep, but the environment variables do not seem to work. Is there a way to use environment variables over a ssh block?
Environment variables over ssh block in shell script
shell script;ssh;quoting;here document
man bash:The format of here-documents is:          <<[-]word                  here-document          delimiterNo  parameter  and variable expansion, command substitution, arithmetic         expansion, or pathname expansion is performed on word.  If any  characters  in word are quoted, the delimiter is the result of quote removal         on word, and the lines in the here-document are not expanded.  If word         is  unquoted, all lines of the here-document are subjected to parameter         expansion, command substitution, and arithmetic expansion, the  character  sequence  \<newline>  is  ignored, and \ must be used to quote the         characters \, $, and `.