How to read a remote environment variable when executing commands using SSH



Hello everbody! I want to execute a command to a remote computer using
SSH. Some of arguements provided to the command are read from
environment variables from the local computers, and some arguements are
read from the environment variables of the remote computer. To give an
example:

Environment variables
-------------------------------
Local: NAME="KOSTIS"
Local: HOSTNAME="LOCAL_COMPUTER"
Remote: NAME="HLEKTRA"
Remote: HOSTNAME="REMOTE_COMPUTER"

What I want to do
--------------------------
I want to create a file named MyFile at the remote computer containing
the phrase "KOSTIS is logged to the REMOTE_COMPUTER"

The command I execute
-----------------------------------
ssh -i identity_file -l username "echo $NAME is logged to the
\$REMOTE_COMPUTER > MyFile"

When I type the command at the shell and I run it, it works perfectly.
The problem is that if I type the command inside a script and I execute
the script, the phrase that is written to the remote file is "KOSTIS is
logged to the LOCAL_COMPUTER".

Any help would be appreciated!!!!!

.



Relevant Pages

  • Re: How to read a remote environment variable when executing commands using SSH
    ... Some of arguements provided to the command are read from ... read from the environment variables of the remote computer. ... I want to create a file named MyFile at the remote computer containing ...
    (comp.unix.shell)
  • How to read a remote environment variable when executing commands using SSH
    ... I want to execute a command to a remote computer using ... Some of arguements provided to the command are read from ... read from the environment variables of the remote computer. ...
    (comp.unix.shell)
  • Execute failed in Ant
    ... When I run the executable from a command line, ... When I execute it as part of ant, ... to set environment variables, ...
    (comp.lang.java.programmer)
  • RE: need help with rsh
    ... "Augie" wrote: ... > I must be able to execute that command, ... > c:\test.bat) on the remote computer. ... I also need to execute on the remote this command: ...
    (microsoft.public.scripting.wsh)
  • Re: Remote install Windows Service
    ... executing a command on a remote computer can be a ... remote computer, although I suspect there might be one. ... | don't how to execute that command in remote computer!! ...
    (microsoft.public.dotnet.languages.vb)