How to get the value of variables after running the script remotely via ssh?

Good day!
Tell me how to solve the problem.

There is a machine 'A' and 'B'

Machine 'A' script that comes via ssh to machine 'B' and run the script.
The script is running, that puts it in the text files that it copies. Initialisere some variables. The question is how do I remotely get the value of variable to itself in machine 'A'.

A-> ssh user@b "cd /to/script && ./script.sh"

B->cat script.sh 
 a=`ls-l | grep 'info`
 b=`dmesg | grep 'error"
c=`date`
do
$a $b $c 
done


How can I get after execution of the script the value of variables to their 'A'?

That would be something like this:

ssh user@b "cd /to/script && ./script.sh"
echo $a $b $c
September 26th 19 at 07:18
3 answers
September 26th 19 at 07:20
In file script.sh add the line
echo \"$a\" is \"$b\" \"$c\"
Then, the values thus obtain
RESULT=`ssh user@b "cd /to/script && ./script.sh"`

And, accordingly, processing:
for command in $RESULT
do
 echo $command
done
Well, maybe a separator of some sort to use, then use it to parse. Meaning, I hope, understandable - Ignatius_Smitham commented on September 26th 19 at 07:23
Or another option:
script.sh
---------
echo a=\"$a\"
echo b=\"$b\"
echo c=\"$c\"
------------
After that (on A):
------------
. <(ssh user@b "cd /to/script && ./script.sh")
------------
And then (also in A)
------------
echo $a - Ignatius_Smitham commented on September 26th 19 at 07:26
September 26th 19 at 07:22
Write them in a file in tmp and do anything :)
September 26th 19 at 07:24
A possible example as it to make competently?
I mean? You pull the script via SSH on the remote machine. He's out there doing something, using some variables. You the values of these variables are put in a file and refer to it. Even then his car to drag through rsync and take values from there. - Ignatius_Smitham commented on September 26th 19 at 07:27

Find more questions by tags bashCommand lineSSH