I am executing a script on a remote ssh host as follows:
ssh -tt $USER@somehost 'bash -s' < ./myscript.sh
You are missing an
I suspect the reason that the
exit is necessary is becase when you force allocation of a pty, the pty is expecting the input to be a terminal... Reading
EOF from a terminal doesn't mean 'there is never, ever any more data to come' the way it does for a pipe / file - it just means that there is 'currently no more input from the user' - hence the hang... it's waiting for further input.
This input script (
echo "Hello World..."
echo "Hello World..." exit 0