1

Running into a bit of an issue while trying to add a user prompt check to a existing script which was already working.

Here is the existing script, which is working...

#!/bin/sh

echo "**** Pulling changes into Production"

ssh [email protected] "$( cat <<'EOT'
    cd example.com/html/ || exit
    unset GIT_DIR
    git pull
EOT
)"

Here is my modified script with a user prompt, which is broken.. and it is only broken when I add the ssh line. Works perfectly with just echoes.

#!/usr/bin/env bash
while true; do
    read -p "Are you sure you want to pull changes into production? [y/N] " yn
    case $yn in
        [Yy]* ) 
            ssh [email protected] "$( cat <<'EOT'
                cd example.com/html/ || exit
                unset GIT_DIR
                git pull
                EOT
            )"; 
            exit;;
        [Nn]* ) 
            echo "!!!! CANCELLING !!!!"; 
            exit;;
        * ) echo "Please answer yes or no.";;
    esac
done

The error I'm getting is...

Syntax error: end of file unexpected (expecting ")")

1 Answer 1

2

EOT must appear at the beginning of the line. Your EOT appears somewhere in between, with lots of leading spaces.

Replace

                EOT

By

EOT
Sign up to request clarification or add additional context in comments.

2 Comments

I would move the ssh part to a function and call that function from the case expression.
That's what I get for trying to make the code look clean! Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.