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