How can I pass an array across the ssh connection.
I have an array formed thus:
declare -a target_array=(
"item1 -p12345 -r"
"item2 -p65677 -e"
)
I then need to pass it to an ssh connection as follows:
ssh $server target_array=${target_array[@]}" "bash -s" <<TARGETSCRIPT
echo "hello"
TARGETSCRIPT
But this just gives me the error:
bash: -p12345: command not found
What is the best way to do this? I've tried with and without {}
, with and without [@]
but nothing seems to work.
(n.b. that echo hello
is just a placeholder for an 800 line script that makes use of the target_array).