bash variable expansion piped to ssh

Viewed 244

I can't get my head around how to declare / refer to these variables in a shell script.

Given the contents of commands_to_execute_on_remote.sh as:

for c in 1 2 3 4 5
do
    supervisorctl restart broadcast-server-${ENVIRONMENT_NAME}-${c}
done

Where ENVIRONMENT_NAME is declared as an environment variable on the local machine...

When I'm running this from a local machine as, e.g.:

cat commands_to_execute_on_remote.sh | ssh user@123.456.789

How do I refer to those variables in order that, by the time the script is piped to the remote box, $ENVIRONMENT_NAME is populated with the actual value but $c is - obviously - a loop counter within the script?

1 Answers
Related