I am trying to access my local variable in remote server. Which command should I use.
Ex. cmd:
SERVER 1 VAR=2 ssh unix-user@remote-server-name "bash abc.sh"
REMOTE SERVER:
cat abc.sh echo $VAR
output should get 2
.
Advertisement
Answer
Set the variable directly on the remote side:
ssh unix-user@remote-server-name "export VAR=2; bash abc.sh"