Whenever I try to use the variable declared inside my SSH session it gives me blank output. Here is the code which I am trying to execute:
ssh -T host <<\HERE
export usage1=$(df -h |grep /nas/infa|sed s/%//g| awk '{printf("%d\n",$4)}');
echo $usage1
HERE
echo $usage1
I am able to get the desired output inside the SSH session, but when calling the same variable outside the SSH it gives me blank.
To get the value from the remotely executed command into a variable in your local environment, it's the same as getting the value of a locally executed command into your local environment, e.g.,
export usage1=$(ssh -T host <<\HERE
df -h|grep /nas/infa|sed s/%//g|awk '{printf("%d\n",$4)}'
HERE
)
echo $usage1
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments