Tom,
If you know your way around zendmd, it looks like the following methods might help:
device.getUserCommands() - returns a list of "command" objects
device.compile(command,device) - returns the "command line" string
you could write a script to be executed from command line (see http://wiki.zenoss.org/ZenDMD_Tips) that would perform the device lookup and return the desired command.
Another option may be to see if the "compile" (or some other) method is available through the JSON API.
Hope this helps,
Joseph