Hello I have a problem in Bash scripting with executing command from other user, when trying to call there my own variables.
It doesn't work:
PATH='/home/test'
sudo -u test -s /bin/bash -c 'rsync -az $PATH/ test@server1.example.com:$PATH'
It works only when I change the $PATH to /home/test
which is not suitable. If will use another variable instead of PATH the result still the same. Problem that I do not know how to variables, when calling remote command. Is there any way to execute this command?