The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 11-19-2007
gus2000 gus2000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 157
Indeed, you have an open-ended single-quote which should be closed.

But...you have bigger problems than that, because this is a *remote* script. So, statements like this:

Code:
ssh HOST <<EOF
    echo $HOSTNAME
EOF
will show the local value of HOSTNAME, since the script is evaluated by the shell before it is sent to the remote host. So, all variables that you don't want evaluated need to be escaped (i.e., "\$HOSTNAME"). If you don't need to reference ANY local variables, you can prevent the script from being evaluated be escaping the "EOF" separator:

Code:
ssh HOST <<\EOF
    # the backslash above will prevent the Variables below from being evaluated
    echo $HOSTNAME
EOF
Generally, when attempting to code/debug these kinds of scripts, you should send them to a local file to ensure the code evaluates the way you expect, and then you can run "sh -n" to verify the syntax:

Code:
cat <<EOF > /tmp/test.script
    # this is a temporary location
    echo $VALUE1 \$VALUE1
EOF