I would like to write a Publish Service that would work like the built-in Hard Drive Publish Service. Only thing I would like to add there would be running some external programs through LrTasks.execute(). I have tried to study the sDK material but getting pretty much nowhere there.
I would suggest writing a publish service and putting debug-logs in various places to see what's being called when.
In particular, processRenderedPhotos function of export/publish service provider might be a good place for that command-line program to run (publish services do not support export filters which may be a good hook if its a plain export - not publish service)
You can start with the flickr plugin in SDK and strip it down to bare bones, or use the Plugin Generator plugin that's included with the Elare Plugin Framework, and simply set publish=true in the advanced settings to have a skeletal publish service plugin created for you.