Trying to call a handler via osascript (and failing)

I need to call an AppleScript script from a library via its handler in a shell script. I have this:

osascript -e 'script \"myLibrary\"'s test()'

I think I need to escape the brackets too but nothing I try seems to work. Any help greatly appreciated!

I think anything passed that way has to be standalone. It doesn’t look as if either of those names (myLibrary, and test) are actually bound to anything there.


The problem’s confusion between the single quotes and the apostrophe. This works:

do shell script "osascript -e " & quoted form of "script \"myLibrary\"'s test()"

As do:

do shell script "osascript -e  'test() of script \"myLibrary\"'"

… and …

do shell script "osascript -e  'tell script \"myLibrary\" to test()'"

Brilliant thank you! Sometimes it’s the simplest things that stump me.