F
F
frolin2014-07-27 17:57:32
bash
frolin, 2014-07-27 17:57:32

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

Good afternoon!
Please tell me how to solve the problem.
There is a machine 'A' and 'B'
Machine 'A' a script that ssh to machine 'B' and runs the script.
The script is executed, puts something into text files, copies something. Initializes some variables. And now the question is how can I remotely pull out the value of the variables to my machine 'A'.

A-> ssh [email protected] "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 it is possible to pull out after working out of a script value of variables to itself on 'A'?
What would be something like this:
ssh [email protected] "cd /to/script  && ./script.sh"
echo $a $b $c

Answer the question

In order to leave comments, you need to log in

3 answer(s)
3
3vi1_0n3, 2014-07-27
@3vi1_0n3

Add a line to the script.sh file
. After that, it will be possible to get the values ​​in this way
And, accordingly, process:

for command in $RESULT
do
  echo $command
done

I
Ingtar, 2014-07-27
@Ingtar

Write them to a file in tmp and do whatever :)

F
frolin, 2014-07-27
@Fralunia

Can you give an example of how to do it correctly?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question