Thanks Kiwidude! I've drawn heavily on your code and my attempted plugin is attached. ".txt" should be removed from the name of the script "unpnup.txt". This script then needs to be marked as executable and placed in /usr/bin. Note also the dependencies listed within that script.
The plugin does not throw up any errors but unfortunately doesn't seem to be working properly. It is supposed to create the output split pdf in your home folder (ideally it would create it in your calibre library, or a destination of your choice set under tweaks, but I want to get at least this part working before I try to do anything like that).
I installed the plugin and set the new plugin to display in the context menu of the library under Preferences->Toolbars. It's very difficult to work out what is going on, since Calibre seems to excecute the process but gives no feedback, and after a long wait the file still has does not appeared. Is there any way to get this to display as a job in Calibre, so I can see whether it is doing anything? Also, could someone have a look at my code and tell me what I'm doing wrong?