Run function from script over ssh (BASH)

Hi,

Is there any cleaver way to run function from the bash scrip over ssh?

For example:

#!/bin/bash
#Function 1
FN1 ()
{
ls -l
}

#Main run
ssh user@host FN1
exit 0

Yeah, I know it will not work, but I'm asking how to make it to work :slight_smile:
I'm suspecting that it would be impossible to do that, but then one never know!

Many thanks in advance!
Cheers
Chris

When you post code, please wrap it in

 tags.



#!/bin/bash
#Function 1
FN1 () 
{
ls -l
}

#Main run
ssh user@host FN1 
exit 0

Yeah, I know it will not work, but I'm asking how to make it to work :slight_smile:
I'm suspecting that it would be impossible to do that, but then one never know!
[/quote]

[indent]
You must define the function in the remote shell:

ssh user@host "FN1() 
{
ls -l
}
FN1
"