I am trying to execute a script on remote servers, passing the script as the last argument
ntrs exec-all-ubuntu --exec `cat << 'EOF'
echo "$(pwd)"
echo "$foobar"
EOF`
The problem is that the values in the text are sent as separate arguments, echo is the first arg and the pwd value is a second separate arg, but I want just one argument as a string
The arguments end up looking like this:
[ '--exec', 'echo', '"$(pwd)"', 'echo', '"$foobar"' ]
but I am looking for something literal with newlines:
[ '--exec', ' echo "$(pwd)"\n\n echo "$foobar"\n ' ]
I also tried using this:
ntrs exec-all-ubuntu --exec `read -d << EOF
select c1, c2 from foo
where c1='something'
EOF`
but that string is empty