1
votes

I am trying to execute unix command using SSH from cygwin. My set of command would navigate to a certain directory, source a particular file. Based on the variables sourced from that file, I would try to launch application. But somehow the variables are not getting sourced as echo does not return any values. Could someone let me know what am I missing here

Contents of the environment variables file (myenv) are

export TEST_DATA="DATA1:DATA2"

and I am executing the following command

$ ssh kunal@kspace "ls; cd /disk1/kunal/env; . ./myenv; echo $TEST_DATA; "
2

2 Answers

3
votes

Double quotes do not inhibit expansion. Use single quotes instead.

That is, the variable is being expanded on your side, not on the server you're SSHing to.

1
votes

Because $TEST_DATA is in double quotes, its value is being interpolated by your local shell (the one you called ssh in). If you use single quotes it will pass the literal $TEST_DATA across as part of the ssh command to be executed on the far side.