Skip to main content
typo-fix; nothing specific to bash here
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

I have a script that will ssh to another server.

Script A will get the value of $variableA, then will ssh to another server to execute a script B which will need the value of $variableA.

I tried below but script B is not recognizing the value of $variableA

scriptA"

varA=`hostname`
ssh -x serverB "/home/dir/scriptb.sh $varA"

Script B from 2nd server:

echo $varA

ScriptB from 2nd sserver wontserver won't echo $varA.

I have a script that will ssh to another server.

Script A will get the value of $variableA, then will ssh to another server to execute a script B which will need the value of $variableA.

I tried below but script B is not recognizing the value of $variableA

scriptA"

varA=`hostname`
ssh -x serverB "/home/dir/scriptb.sh $varA"

Script B from 2nd server:

echo $varA

ScriptB from 2nd sserver wont echo $varA

I have a script that will ssh to another server.

Script A will get the value of $variableA, then will ssh to another server to execute a script B which will need the value of $variableA.

I tried below but script B is not recognizing the value of $variableA

scriptA"

varA=`hostname`
ssh -x serverB "/home/dir/scriptb.sh $varA"

Script B from 2nd server:

echo $varA

ScriptB from 2nd server won't echo $varA.

Source Link

pass the value of variable from a script to another script from another server

I have a script that will ssh to another server.

Script A will get the value of $variableA, then will ssh to another server to execute a script B which will need the value of $variableA.

I tried below but script B is not recognizing the value of $variableA

scriptA"

varA=`hostname`
ssh -x serverB "/home/dir/scriptb.sh $varA"

Script B from 2nd server:

echo $varA

ScriptB from 2nd sserver wont echo $varA