user@slave $ source ssh user@master "/service/dyn.master.setenv.sh --mode=slave"
The var is not setting and I am getting various errors. How can I do a remote "source" of a bash script file (from master.example.com) and set a shell variable locally at slave.example.com?
|Estimated completion time||N/A|
You need to use eval or source command as follows to fix your problem:
source <(ssh user@server cat /path/to/varfile)
eval $(ssh user@master cat /path/to/varfile)
Create a file called /tmp/foo on master server called master.example.com as follows:
JAIL=/lighttpd PHP=/opt/bin/php5-cgi MINIMAIL=/opt/bin/chroot-sendmail
Type the following command on server/workstation called slave.example.com (please note that [user@slave ~]$ is your prompt):
[user@slave ~]$ source <(ssh email@example.com cat /tmp/foo) [user@slave ~]$ echo "$JAIL $PHP $MINIMAIL"
[user@slave ~]$ eval $(ssh firstname.lastname@example.org cat /tmp/foo) [user@slave ~]$ echo "$JAIL $PHP $MINIMAIL"
Following sample session uses localhost computer as a master and slave. However, the concept remains same for master.example.com and slave.example.com Server.