On Tue, 27 Nov 2007, gajendrasharma1 wrote:
>a=10
>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
>command.
hi, this should definitely work since ssh knows nothing about that,
it's just about the remote shell that is run with -c "<the code>"; 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
#!/bin/sh
echo $a
$ ssh localhost "export a=xx; ./test.sh"
xx
the same with 'ssh localhost "a=xx ./test.sh"'
J.
--
Jan Pechanec