On Mon, Mar 27, 2023 at 12:24:35PM -0700, L A Walsh wrote: > interactive: > > readarray out< <(ssh -n -T "$user@$host" 'printf "1\n2\n3\n4\n5\n"' 2>&1); > printf "%s" "${out[@]}"
> In script: > > on_host athenae 'printf "1\n2\n3\n4\n5\n"' Using host athenae > 103: host athenae, up > Read 1 lines You aren't showing the actual commands that the script is running, so we have no way to verify that whatever the script is doing is identical to what you were doing interactively. Also: > readarray output< <(ssh -n -T "$user@$host" "$@" 2>&1) That "$@" is not going to work the way you want it to in the general case. The arguments that are passed to ssh to form a command are pasted together with spaces between them, and then parsed by the remote shell. This can lead to all kinds of brokenness if you aren't planning around it. See also <https://mywiki.wooledge.org/BashFAQ/096>. I don't know whether that's immediately relevant to your stated problem, but it's definitely a future problem waiting to bite you.