Reputation: 377
I'm trying to make a script that uses variables from a remote script. Currently the script executes the remote script with an ssh user@server "/route/to/script.sh" command in the script. In that script I'm saving some variables. I wish to use these variables in my local script where I've began everything.
Any ideas how to do this?
Regards: Bert
Upvotes: 0
Views: 701
Reputation: 59426
Lots of options possible. One could be:
a=$(ssh user@server "/route/to/script.sh")
While the remote script.sh
looks something like this:
#!/bin/bash
hostname
This way, the output of the command hostname
(should be the name of the remote host) will end up in the local variable a
.
Upvotes: 1