I am trying to execute a function via SSH. I am able to do it after following this post.
But if I have some global/environmental variable in the shell script those are not expanded. Here is the source code of the file to SSH node is not an option since its like a local copy.
Ex i tried:
#!/bin/bash
SKS="TYPO"
fun2(){
arg=$1
echo $arg >> /tmp/a.o
echo $SKS >> /tmp/a.o
}
fun1() {
echo "SKSKSKSKS" > /tmp/a.o
fun2 "SPSP"
}
fun1
SSH="ssh -4q -o StrictHostKeyChecking=no -o ConnectTimeout=10"
$SSH <ssh-host> "$(typeset -f); fun1"
When I executed this script on the local node it gave me output as:
cat /tmp/a.o
SKSKSKSKS
SPSP
TYPO
but on the SSHed node its:
SKSKSKSKS
SPSP
So here $SKS
is not expanded on the SSHed node.
Please help me to resolve this.
Regards, Shridhar