Skip to main content
formatting; edited tags
Source Link
Gilles 'SO- stop being evil'
  • 866.1k
  • 205
  • 1.8k
  • 2.3k

I'm need to get the value of a variable from a remote host in a script using SSH and have to source an environment file first that does a shift at the end of it'sits run.

The command works locally and I can see what it's doing with an echo. I've spent a good day researching this and testing every combination of single and double quotes I could find. I hope someone has a quick solution.

The first SSH command returns "YES" which is what I expect. How do I get the second variable to the remote host without it being expanded?

Here's the script:

#!/bin/ksh
 
set -x
 
SIDHost=p16
 
ThisSID=test
 
ssh -q $SIDHost "". /tmp/useq $ThisSID; echo \$HOST_IS_ERPDB"
\$HOST_IS_ERPDB"
ERPTest=\`sshERPTest=`ssh -q ${SIDHost} "". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo \$HOST_IS_ERPDB"\`\$HOST_IS_ERPDB"`

Script run:

\++ SIDHost=p16
 
\++ ThisSID=test
 
\++ ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo $HOST_IS_ERPDB
 
YES
 
\++ + ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo NO
 
ERPTest=NO 

I'm need to get the value of a variable from a remote host in a script using SSH and have to source an environment file first that does a shift at the end of it's run.

The command works locally and I can see what it's doing with an echo. I've spent a good day researching this and testing every combination of single and double quotes I could find. I hope someone has a quick solution.

The first SSH command returns "YES" which is what I expect. How do I get the second variable to the remote host without it being expanded?

Here's the script:

#!/bin/ksh
 
set -x
 
SIDHost=p16
 
ThisSID=test
 
ssh -q $SIDHost ". /tmp/useq $ThisSID; echo \$HOST_IS_ERPDB"

ERPTest=\`ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo \$HOST_IS_ERPDB"\`

Script run:

\+ SIDHost=p16
 
\+ ThisSID=test
 
\+ ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo $HOST_IS_ERPDB
 
YES
 
\+ + ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo NO
 
ERPTest=NO

I'm need to get the value of a variable from a remote host in a script using SSH and have to source an environment file first that does a shift at the end of its run.

The command works locally and I can see what it's doing with an echo. I've spent a good day researching this and testing every combination of single and double quotes I could find. I hope someone has a quick solution.

The first SSH command returns "YES" which is what I expect. How do I get the second variable to the remote host without it being expanded?

Here's the script:

#!/bin/ksh
set -x
SIDHost=p16
ThisSID=test
ssh -q $SIDHost ". /tmp/useq $ThisSID; echo \$HOST_IS_ERPDB"
ERPTest=`ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo \$HOST_IS_ERPDB"`

Script run:

+ SIDHost=p16
+ ThisSID=test
+ ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo $HOST_IS_ERPDB
YES
+ + ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo NO
ERPTest=NO 
Formatting
Source Link
jasonwryan
  • 74.9k
  • 35
  • 204
  • 230

I'm need to get the value of a variable from a remote host in a script using sshSSH and have to source an environment file first that does a shift at the end of it's run. 

The command works locally and I can see what it's doing with an echoecho. I've spent a good day researching this and testing every combination of single and double quotes I could find. I hope someone has a quick solution.

The first sshSSH command returns "YES" which is what I expect. How do I get the second variable to the remote host without it being expanded? Thanks...

Here's the script:

#!/bin/ksh

set -x

SIDHost=p16

ThisSID=test

ssh -q $SIDHost ". /tmp/useq $ThisSID; echo $HOST_IS_ERPDB"

ERPTest=`ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo $HOST_IS_ERPDB"`

#!/bin/ksh

set -x

SIDHost=p16

ThisSID=test

ssh -q $SIDHost ". /tmp/useq $ThisSID; echo \$HOST_IS_ERPDB"

ERPTest=\`ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo \$HOST_IS_ERPDB"\`

Script run:

+ SIDHost=p16

+ ThisSID=test

+ ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo $HOST_IS_ERPDB

YES

+ + ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo NO

ERPTest=NO

\+ SIDHost=p16

\+ ThisSID=test

\+ ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo $HOST_IS_ERPDB

YES

\+ + ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo NO

ERPTest=NO

I'm need to get the value of a variable from a remote host in a script using ssh and have to source an environment file first that does a shift at the end of it's run. The command works locally and I can see what it's doing with an echo. I've spent a good day researching this and testing every combination of single and double quotes I could find. I hope someone has a quick solution.

The first ssh command returns "YES" which is what I expect. How do I get the second variable to the remote host without it being expanded? Thanks...

Here's the script:

#!/bin/ksh

set -x

SIDHost=p16

ThisSID=test

ssh -q $SIDHost ". /tmp/useq $ThisSID; echo $HOST_IS_ERPDB"

ERPTest=`ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo $HOST_IS_ERPDB"`

Script run:

+ SIDHost=p16

+ ThisSID=test

+ ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo $HOST_IS_ERPDB

YES

+ + ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo NO

ERPTest=NO

I'm need to get the value of a variable from a remote host in a script using SSH and have to source an environment file first that does a shift at the end of it's run. 

The command works locally and I can see what it's doing with an echo. I've spent a good day researching this and testing every combination of single and double quotes I could find. I hope someone has a quick solution.

The first SSH command returns "YES" which is what I expect. How do I get the second variable to the remote host without it being expanded?

Here's the script:

#!/bin/ksh

set -x

SIDHost=p16

ThisSID=test

ssh -q $SIDHost ". /tmp/useq $ThisSID; echo \$HOST_IS_ERPDB"

ERPTest=\`ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo \$HOST_IS_ERPDB"\`

Script run:

\+ SIDHost=p16

\+ ThisSID=test

\+ ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo $HOST_IS_ERPDB

YES

\+ + ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo NO

ERPTest=NO
Source Link

Remote ssh command not sending echo variable from a ksh script on AIX

I'm need to get the value of a variable from a remote host in a script using ssh and have to source an environment file first that does a shift at the end of it's run. The command works locally and I can see what it's doing with an echo. I've spent a good day researching this and testing every combination of single and double quotes I could find. I hope someone has a quick solution.

The first ssh command returns "YES" which is what I expect. How do I get the second variable to the remote host without it being expanded? Thanks...

Here's the script:

#!/bin/ksh

set -x

SIDHost=p16

ThisSID=test

ssh -q $SIDHost ". /tmp/useq $ThisSID; echo $HOST_IS_ERPDB"

ERPTest=`ssh -q ${SIDHost} ". /usr/vmmc/bin/oracle_scripts/useq $ThisSID; echo $HOST_IS_ERPDB"`

Script run:

+ SIDHost=p16

+ ThisSID=test

+ ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo $HOST_IS_ERPDB

YES

+ + ssh -q p16 . /usr/vmmc/bin/oracle_scripts/useq test; echo NO

ERPTest=NO