I'm trying to create a single script that connects to a remote server and executes an update, but I want to make sure no one is using the machine at the time so I execute a "ps" command to see the process and then prompt if the installation should continue. Here's the code I'm attempting to make:

```
ssh -T root@$machine <<- 'END'
    #Show the non-root processes
    ps -ef | grep -v root

    #Prompt if should continue (this doesn't work)
    echo "Continuar a instalação? [y/n]"
    select valor in y n
    do
        case $REPLY in
            y )
                echo "Digitado y"
                break
                ;;
            n )
                echo "Digitado n"
                exit
                ;;
        esac
    done

    #Test if it's working
    echo "Test"
END

```

When I execute this code, I get the following behaviour:

```
Continuar a instalação? [y/n]
1) y
2) n
#? 1) y
2) n
#? #? 1) y
2) n
#? #? 
#? 1) y
2) n
#? #? #? 1) y
2) n
#? #? #? #?

```

And then the script closes. I tried running ssh with the -t -t option but I still get the same problem. What am I missing?