Reputation: 257
I try to import variables of a remote bash script via ssh.
Remote file comlink.sh:
#!/bin/bash
test=1
new=2
ready=1
Local file:
#!/bin/bash
ssh pi@[myIP] "cat /home/pi/comlink.sh"
echo $ready
But the variable has no value. Am I missing something?
Upvotes: 1
Views: 285
Reputation: 124646
If you are absolutely certain you can trust the content of that file,
then you can use eval
to execute its content in the current shell,
thereby "importing" those variables:
eval "$(ssh pi@[myIP] "cat /home/pi/comlink.sh")"
Upvotes: 1