I know I can call variables from the local shell in an SSH session, so I assumed I could call a function this way too. But this doesn't seem to work.
I have a script that checks if my local machine can handle certain operations and if it can I need to call local functions, if the local machine cannot I need to SSH into a remote machine and call the local functions.
canHandle() {
if [ -d /this_must_exist/ ]
then
return 0
else
return 1
fi
}
localFunction() {
// Predefined tasks
}
canHandle
if [ $? -eq 0 ]
then
// Process locally using predefined functions
localFunction
else
ssh -t me@server << ENDSSH
// Process remotely calling predefined local functions
localFunction
ENDSSH
fi