Is it possible to call a function from another script?
Thanks
Is it possible to call a function from another script?
Thanks
Sort of.
# file1
foo()
{
echo "foo was called"
}
#file2
# source file1
. file1
# call the any function in file1
foo
Great thanks very much
Lets say I have two scripts A and B.
Script A is using a function in B
So I use . scriptB to get access to all functions.
This works fine if I run scriptA in directory that scriptB is in, but it does not seem to work if I run it in another directory?
create an absolute path. assume scriptB live in /home/chrisj
. /home/chrisj/scriptB
Source scriptB using its full pathname.
. /path/to/scriptB
Thanks stating full path works fine