Trying to pass local variable to remote shell using bash script. Here is what I am trying. This is test.sh
#!/bin/bash
envi=$1
function samplefunction {
echo "Environment selected is $envi"
}
if [ "$envi" = "test" ]; then
ssh user@remotehost <<EOF
$(typeset -f samplefunction)
samplefunction
EOF
else
echo "Please pass correct parameter which is - test"
fi
When I try to execute "./test.sh test" the result I am getting is "Environment selected is". shell is not able to pass the variable to the remote system.