Above seems to work between two systems running bash (or sh ) each. What be the shell on the remote system? Do you know if the errors occur on the remote or local host?
As others have pointed out, setting a function on your system doesn't make the function exist on a remote system.
I'll also point out that $(typeset -f) is run on your local system, before ssh is even run. This is because you've put it inside double quotes, which will evaluate variables, backticks, and $( ) before processing the command.
Thank you for all responses.
Using heredoc is the alternative i'm indeed using right now.
I'm trying to find a better way because I have several functions and need to use them locally AND remotely and don't want to declare the functions more than once.
I'm aware that typeset is evaluated locally, otherwise it won't contain the function and in that case is useless
Chubler_XL, that's look promising, I already tried a similar thing, but it still output a problem.
I guess that there is something with bash version here
mine:
bash --version
GNU bash, version 3.2.51(1)-release (x86_64-suse-linux-gnu)
new output:
Unmatched ".
{: Command not found.
for: Command not found.
do: Command not found.
var: Undefined variable.
done: Command not found.
Unmatched ".