I want to use the variable declared inside an SSH session to be used locally in my shell script

Aishwarya Jhawar

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.

ocurran

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.

edited at
0

Comments

0 comments
Login to comment

Related

Run shell script inside ssh session inside Jenkinsfile

my shell script inside shell script not getting int variable

Can I use the variables declared in useEffect inside of my render in reactstrap?

how can I use a declared variable inside SWIFTUI body view

"The value of the local variable SoundButton38 is not used" But I Want To Use It?

I want to use embedded Browser inside of my WebPage in React

How to use {old,new}name inside a shell script variable?

Trying to use Applescript variable in curl command inside do shell script

want to su without password inside shell script

Use variable inside this constant declared in angular services

How do I pass a variable from a shell script to my .muttrc?

How can i switch my variable slideIndex declared to put it inside the object?

How can i define a variable inside of my class if its declared in a function outside of the class

Why can't i define my previously declared extern variable inside a function?

Check whether ssh is possible inside shell a script?

How do I create a shell script that will exit the ssh session after executing the remote commands

How can I use a variable with a value which is declared inside a function, in javascript?

Question: i've found a strange function that use an externally declared variable inside a cursor where clause

I want to use shell scripting to run my java program for each of my input files

My variable changes (though I don't want to) once I change the other variable I used to set it up

shell script how to use $variable

Use of variable name in shell script

Why can't I use my variable inside this if statement?

I want to make a variable in my views.py which changes depending the name of the urlpattern used

Variable passed to shell script used by awk

i want create shell script file

I want to use wget with variable

Running functions that were declared outside my shell script

"if [ -z $variable ]" in a shell script is not recognising my variable