Oh, and there's always the
JDBC API, which allows you to execute SQL queries to
retrieve events and traces (in full or the overviews) by time, while still supporting the Lucene DB query syntax for finding the correct agent and component:
[font=Courier New]select * from trace_headers where timestamp between '05/09/13 00:00:00' and '05/09/13 23:59:59' and query='host:maddleman-dt2 AND agent:Tomcat'
select * from traces where timestamp between '05/09/13 00:00:00' and '05/09/13 23:59:59' and query='host:maddleman-dt2 AND agent:Tomcat' limit 1[font]
You could create a simple Java application that accepts command line arguments, builds and executes the query, and outputs the results to stdout.