Using a ksh script, I’m trying to get the value of an environment variable from a remote host and store it into a variable of my ksh script. For example, on the remote host, the value $mypath is
/dir1/dir2/dir3
So on my local host from my ksh, I was figuring I could do something like
ssh user@remotehost "echo $mypath”
But not sure what else to do after that if I want to assign it to a variable like myremotepath.
So far if I use this from my ksh script:
ssh user@host 'ls -l'
ssh user@host 'echo "HI"'
ssh user@host 'echo $my_env_var'
The output is below. The ls and first echo command work, why wouldn't the 2nd echo work? I've verified my_env_var is defined on the remote host.
15:12:25 # ~/my.ksh
total 16
-rw-r--r-- 1 user group1 40 Jul 15 15:06 myremote2.txt
-rw-r--r-- 1 user group1 1 Jul 15 13:28 myremote.txt
-rw-r--r-- 1 user group1 22 Jun 29 15:29 tempR.txt
-rw-r--r-- 1 user group1 3 Jun 29 16:11 temp.txt
HI