0

I try to send an SSH command to a remote server. The command is either issued directly in the shell (bash) or from a Makefile:

ssh me@server "rsync -avz /my/stuff $SCRATCH/my/stuff"

$SCRATCH is an environment variable on the remote server, and properly set there. But unfortunately, my local system will try to replace $SCRATCH by a local environment variable before sending the SSH command.

How can I prevent that?

Michael
  • 7,407
  • 8
  • 41
  • 84

1 Answers1

3

Escape $ sign with a backslash to prevent local variable expansion:

ssh me@server "rsync -avz /my/stuff \$SCRATCH/my/stuff"
RomanPerekhrest
  • 88,541
  • 4
  • 65
  • 105