On Tue, 27 Nov 2007, gajendrasharma1 wrote:

>ssh -l $user $host "export myVar=$a; cd $myDir; ./myScript.sh"
>this doesn't work, as probably the ssh shell might not understand the export

hi, this should definitely work since ssh knows nothing about that,
it's just about the remote shell that is run with -c ""; if you
expand the variable locally (which you did in the example above) it's ok.

however, you can also use SendEnv/AcceptEnv with OpenSSH.

this just works for me:

$ cat test.sh

echo $a

$ ssh localhost "export a=xx; ./test.sh"

the same with 'ssh localhost "a=xx ./test.sh"'


Jan Pechanec