Re: How to export variables on remote machine through ssh.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Open SSH Unix Development]     [Fedora Users]     [Fedora Desktop]     [Yosemite Backpacking]     [KDE Users]     [Gnome Users]

  Powered by Linux