Hello to all
Background info:
Local machine : Linux, /bin/bash
Remote machine (for the user used for ssh) : SunOs, /bin/ksh
(so we have different OS, different Shells)
My problem :
From the local host i execute
$ var=bla
$ result=$(ssh -q user@remote-machine "
> echo \"this is var: $var \"
> var2=ggg
> echo \"this is var2 : $var2 \"
> "
> )
$ echo "$result"
this is var: bla
this is var2 :
So, as you can see I want to open a ssh session on a remote machine and a want to shift a variable there also (in my case variable $var ). From what I know I can only do that by using the syntax : ssh user@machine " command " , so I used double quotes to describe the commands which I wanna execute via ssh. So, from my example you can see that I can shift the $var variable on the remote session, but I cannot create and/or call (?) another variable $var2 .
If I use ' ' (simple quotes) instead of " " . I can create the variable $var2 , but I cannot shift the variable $var .
I tried the same thing when the remote machine was Linux with /bin/sh shell for the user used for ssh. The results are the same, so I don't think it is an issue of different OS or different shells
Any ideas?
P.S. : i dont want to use workarounds such as declare $var in a file, scp the file on the remote host and source it there.
P.P.S. I cannot use rsh, remotexec.