RT Batch Creation and Edits

RT has fairly simple scriptable tools for batch ticket creation and edits.


RT has powerful scriptable tools for batch ticket creation and edits.

There are two methods to do batch edits on existing tickets. The first is within the RT web interface, once you have results from a search. See below for more details. The second method is from a linux/unix command-line and is documented on this page.

The rt command-line tool also makes it easy to create new tickets in a batch, which is not possible from the RT web interface.

All RT fields can be updated from the command-line tool, except for the Custom Roles we're no longer using ("Accountable" and "Supporters"). See below for specifics and a few caviats.


The command-line tool 'rt' is installed on linux.cs.uwaterloo.ca and linux.cscf.uwaterloo.ca. It may be installed on any Ubuntu system with the following installation:

shell:~> sudo apt-get install rt4-clients

On a typical ubuntu server, it will also install libterm-readline-perl-perl but doesn't install any more of the RT server/client dependency chain.

Once the package is installed, all that remains is configuring it for your user.

User Configuration

The rt command-line tool will operate as your userid; so you need your RT login information. Note that it stores the password as plaintext, so the first step below ensures the file is not readable by other users.

  1. Create and set safe permissions:
     shell:~> touch ~/.rtrc && chmod 600 ~/.rtrc
  1. Edit ~/.rtrc to contain:
     server https://rt.uwaterloo.ca
     user yourid
     passwd ***************

And that's all the necessary configuration.

Hello World

Test the following to see if your configuration is correct:
     shell:~> rt show user/drallen
     id: user/2742
     Password: ********
     Name: drallen
     EmailAddress: drallen@uwaterloo.ca
     RealName: Daniel Allen
     Gecos: drallen
     Organization: Computer Science (CSCF)
     Address1: DC 2621
     WorkPhone: 519-888-4567 x35448

     Comments: Autocreated on ticket submission
               daniel.allen@uwaterloo.ca (1491407) merged into this user
               drallen@connect.uwaterloo.ca (1491409) merged into this user
               drallen@connect.uwaterloo.ca (1491409) unmerged from this user

     Privileged: 1
     Disabled: 0

Assuming this works, you're ready to modify a ticket from the command-line.

You can find context-specific help at any time with the command rt help

Modifying a Ticket

If you look at the docs or the rt help, there are often more than one way to do things. These instructions will keep things as simple as possible.

There are different formats for setting fields, adding a transaction such as a comment, and adding links such as See Also, Dependencies, and Children.

Setting Fields

There is a different format for setting fields with one value or multiple values. If you're unsure whether a field can have multiple values, try editing it within RT. Most fields have one value. If there is a checkbox next to it (such as for requestors and admin-cc), it can have multiple values. If it's a custom field, the interface will prompt "Enter one value" or "Enter multiple values".

Setting one or many fields with one value follows the following format:

     rt edit <ticket> set <fieldname='value'> [<fieldname='value'> <fieldname='value'>]


     rt edit 637182 set subject='[Fall2017] Install School Laptop for MMath Thesis student Abbas Abou Daya'  owner='drallen'

Setting one or many fields with more than one value follows the following format:

     rt edit <ticket> add <fieldname='value'> [<fieldname='value'> <fieldname='value'>]


     rt edit 637182 add admincc='drallen' 

The above can be combined into a single command. Sample:

     rt edit 637182 add admincc='drallen' set subject='whatever'  owner='drallen'

Remember that Links are not multiple-value fields; see below for Adding and Removing Links.

Adding Transactions Such as a Comment

     rt comment <ticket> -m "<value>"


     rt comment 637182 -m "this text will be added as a comment to the ticket" 

Adding and Removing Links

There are six named link types:

  • DependsOn / DependedOnBy A depends upon B (or vice versa).
  • RefersTo / ReferredToBy A refers to B (or vice versa).
  • MemberOf / HasMember A is a child or a parent of B.

     rt link <ticket> <typeOfLink> <otherTicket>


     rt link 637182 HasMember 636971 

Deleting a link is done by specifying link -d instead. Sample:

     rt link -d 637182 HasMember 636971

Creating a Ticket

Creating a ticket requires choosing a queue and optionally any other fields. The returned text will include the new ticket id.

     rt create -t ticket set queue=<queue> [<fieldname='value'> <fieldname='value'> <fieldname='value'>]

Sample (with optional extra \ continuation-characters to split the command into shorter lines):

     rt create -t ticket set queue=CSCF-RSG subject='[Fall2017] Install To be determined for MMath Thesis student Mohammed Alfatafta (maaalfat)'\
     set 'CF-Summary (Wiki)'='Supervisor- Al Kiswany, Samer, Room -' 'CF-Subscription Code'='sc-alkiswan' Due='2017-09-05 17:00' priority=3 \ 
     owner=rgarcia add AdminCC=lfolland,pbeldows

The output will be:

     # Ticket 636971 created.

If there are warnings for any fields, they will appear before the creation message. To fix it, you'll need to do an edit on the ticket.

If there is no creation message, you'll have to fix the error and then re-run the create command.

Remarks on creating tickets:

  • All custom fields are preceeded with 'CF-' and custom fields containing a space must be quoted
    • A bug we've discovered: if the custom field name has parentheses in it, and the value has colons in it, it will fail to parse. A workaround is add a comma at the beginning of the value; or somewhere before the first colon. For CSCF, this should only affect the "Summary (Wiki)" field.

Creating a Ticket and Setting Links

You cannot set links (dependencies/children/references) at the same time as you create the ticket. If you want to create a large number of tickets and then add dependencies, there are at least two options: a) two-step command-line; or b) use RT's built-in "Bulk Update"

a) Two Step Command-line

From the output of the create command, you can parse the "created" line to find the ticket numbers you want to operate on, then construct the relevant link command. For example:

     shell:~> rt create -t ticket set queue=CSCF-RSG subject='RT Batch Creation: test subticket 2' set 'CF-Subscription Code'='sc-rt' Due='next wednesday' 
     # Ticket 636974 created.
     shell:~> rt link 636974 DependsOn 777777
     Ticket 636974 depends on Ticket 777777. Created link 636974 DependsOn 777777

b) RT Bulk Update

RT's search-results page has a Bulk Update option. So you can do a search for a unique value in your tickets (perhaps including creation date today); With the results shown, you can do a "Search->current search->Bulk Update" and add a dependency to ticket X.

Extending the Above to Batches of Tickets

The above operations can be combined using chained unix commands and/or bash scripts.

A simple bash script could be created from spreadsheet data; repeating a one-line command to create a batch of tickets, running that script and capturing the output, and parsing that output to construct a script that would create Dependencies. (See directly above for "Two Step Command-line").

Hints and tips

  • Date fields are flexible. You can specify Due="next wednesday" (which will set the time to now on next Wednesday).
  • If you are creating or editing a batch of tickets, be aware that it will send an email to the Requester - so you probably don't want to set the requester to a client before you do a large number of changes.
  • The rt command doesn't yet know about Custom Roles. (new in Version 4.2)
  • See rt help for a large number of additional options. For example, in rt help create we see the following chained unix command:
     rt ls -t tickets -i 'Priority > 5' | rt edit - set status=resolved

See Also


  • bin/rt4
  • bin/rt
  • rt-4
-- DanielAllen - 2017-11-23
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r6 - 2022-07-27 - DanielAllen
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback