I am trying to add a waiting point to my code which can then be resumed/unblocked manually. Sadly it is not working as expected. I guess due to how heredoc works (=stdin).
Could someone suggest another alternative still using heredoc given it keeps the code very clear or any similar syntax serving the same purpose.
username=root
host=blah
ssh -t $username@$host <<-EOF_REMOTE_BASH
## set options
set -x
printf ">>> Connected to %s@%s\n" "$username" "$host"
## loop and run logic
# this is sample loop only
for i in $(seq 1 2 20); do
## some code
# more code
# ...
# ...
# ...
## Wait until unblocked manually
# NOT WAITING!
read -s -n 1 -p "Press any key to continue . . ."
done
## Quit server
exit
EOF_REMOTE_BASH
Edit.1:
username=root
host=blah
ssh -t $username@$host "$(cat<<-EOF_REMOTE_BASH
## prep file
src_file=/tmp/test
cat <<- 'EOF' > ${src_file}
10
20
30
EOF
## Loop over file, wait at each iteration
while IFS="" read -r line || [ -n "\$line" ]; do
echo "\$line"
read -s -n 1 -p "Press any key to continue . . ." && printf "\n"
done <"${src_file}"
EOF_REMOTE_BASH
)"