Friday, 15 February 2013

linux - Environmental/global variables are not expanded in shell script -


I am trying to execute a function via SSH. I am able to do this after following.

But if I have some global / environmental variables in the shell script, then it is not expanded. Here the source code for the SSH node is not an option like a local copy.

Ex: I tried:

  #! / Bin / bash ss = "TYPO" fun 2 () {arg = $ 1 ebb $ arg & gt; /tmp/a.oecho $ sKS & gt; & Gt; /tmp/a.o} Have fun 1 () {echo "SKKsKSKs" & gt; /tmp/a.o fun2 "SPSP"} fun1 SSH = "ssh -4q -o Hardhawk Checking = No-O Connect Timeout = 10" $ ssh < SH-host & gt; When I executed this script on the local node, I gave it the output:  
  cat / tmp /   AO SKKKSKKS SPSXKS SAPP typo  

but on SSH node:

  SKKsKex SSPS  

here $ SKS is not expanded on the SSHed node has been done.

Please help me solve it.

Regards, Sridhar

You can call local $ SKS Expanding the variable typeset -f functions that are not installed or exported on the remote side so that you can get functions on the remote side, but not the variable.

If you want to distribute the variable available to the remote, you either have remote-executed shell scripts or pre-expansions that in any way function on the local side.


No comments:

Post a Comment