4.6. Searching for Tickets

 < Day Day Up > 

Searching with rt involves the list action and TicketSQL. See "Understanding TicketSQL" in Chapter 3 for an introduction to TicketSQL syntax. The command-line interface doesn't provide a query builder to help you out. The following command shows all tickets with a status of new:

     $ rt list "status = 'new'"     3: Bring more coffee rolls! 

The -l option to list provides a long listing, exactly the same as using the show action (see "Finding a Ticket," earlier in this chapter). The -i option only lists object identifiers:

     $ rt list -i "status = 'new'"     ticket/3 

rt passes your TicketSQL query directly to the RT server, which executes the query on your behalf and returns the results for rt to display. You can write arbitrarily complex TicketSQL, just be sure to enclose your entire query within quotes. The following example searches for open tickets in the General queue:

     $ rt list "queue = 'General' AND status = 'open'"     3: Bring more coffee rolls!     5: My frobnitz is broken... again 

If you double-quote the TicketSQL string, most shells will perform variable interpolation, which can be useful. For example, to get your own open tickets (assuming your system login is the same as your RT login), you could use the $USER environment variable:

     $ rt list "status = 'open' AND owner = '$USER'"     5: My frobnitz is broken... again 

Here is an example of the list action, requesting a short list of all tickets which have non-closed Status.

     $ rt list -s -t ticket "Status != 'closed'"           1: a new ticket     21: A request subject line     42: A special number     ... 

Another, more useful example shows the LIKE query string for approximate matches. The following example also uses the -o option to order the output based on the status field rather than the default id.

     $ rt list -s -o +status "status != 'closed' \     > AND subject LIKE 'request'"           21: A request subject line     ... 

The following example uses the -i switch to return only object-ids from the list action. You can feed these results directly into another rt action such as show or edit, which in turn uses the - switch to take the object-ids from STDIN. The following example searches for a list of tickets that aren't closed and shows details for each.

     $ rt list -i "Status != 'closed'" | rt show -           id: ticket/1     Queue: General     Owner: Nobody     Creator: root     ...           --           id: ticket/42     Queue: General     Owner: Nobody     Creator: root     ... 

You can use the same strategy to update multiple tickets at the same time, for example, to add a cc address to all tickets with "urgent" in the subject:

     $ rt list -i "Subject LIKE 'urgent'" | rt edit - add cc=bigboote@example.com     # Ticket 45 updated.     # Ticket 44 updated.     ... 

     < Day Day Up > 


    RT Essentials
    RT Essentials
    ISBN: 0596006683
    EAN: 2147483647
    Year: 2005
    Pages: 166

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net