importing functions from an external bash script

Hi all,

I'm trying to import some functions I have saved in a file named
functions.sh into a different script (protocol.sh). Can anybody show
me how to do this? I tried source functions.sh as I would do at the
terminal but source command cannot be found from within the script
protocol.sh.

thanks in advance,
Tom

Source is good. Reusing functions is a fantastic idea. Few people do this and it is really mportant thing to do. Good for you.

Put the functions from other script into a known, always-will-be-there directory/file

. /path/to/always/functions.sh

We have /usr/local/common for our function libraries. And some other reusables.

1 Like

Frankly I did this but tried to execute protocol.sh with sh rather than bash, and thus I was getting the error message "function: not found". Silly me! Thanks for the help!