Ah, that clarifies the actual difference.<div><br></div><div>Thanks for sharing :)</div><div><br clear="all">-- Bart<br>
<br><br><div class="gmail_quote">Op 23 november 2011 20:29 schreef Kevin Falcone <span dir="ltr"><<a href="mailto:falcone@bestpractical.com">falcone@bestpractical.com</a>></span> het volgende:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Wed, Nov 23, 2011 at 11:06:12AM -0800, Yan Seiner wrote:<br>
> The recent discussion on modifying custom fields got me thinking.... What<br>
> is the difference between using rt and rt-crontool?<br>
<br>
</div>bin/rt is a general purpose tool that uses the REST interface<br>
rt-crontool is intended to glue together existing<br>
RT::Search/RT::Condition/RT::Action/RT::Templates.<br>
<br>
For example, I could do your bin/rt script as a CreateTickets action<br>
with a custom Template.<br>
<br>
If the search, condition and action you want already exist (such as<br>
bumping priority on tickets after 5 days without an owner) then<br>
rt-crontool is going to just work with a lot less code than recreating<br>
that in bin/rt.<br>
<br>
Also, looping over hundreds of tickets should be faster in rt-crontool<br>
rather than bin/rt because it uses the API rather than making tons of<br>
HTTP requests.<br>
<span class="HOEnZb"><font color="#888888"><br>
-kevin<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> Seems that both can do slightly different things and are really different<br>
> tools. The name makes it seem like rt-crontool is somehow preferred when<br>
> running a scheduled job, but I can't think of a reason why rt could not be<br>
> used in a cron job.<br>
><br>
> Here's a script I use to create a linked ticket from an email:<br>
><br>
> #!/bin/bash<br>
><br>
> # exim helper script for adding an invoice ticket to a work order<br>
><br>
> # create a temp file and dump stdio into it<br>
> t=$(tempfile --directory=/tmp) || exit 1<br>
> cat - > $t<br>
><br>
> # we create the ticket<br>
> subject=$(grep -i '^subject:' $t | sed -e 's/^.*: *//')<br>
> ticket=$(/opt/rt4/bin/rt create -t ticket set queue="Water Invoices"<br>
> subject="${subject}" | sed -e s/[^0-9]//g)<br>
> parent=$(/opt/rt4/bin/rt ls -i "'CF.{Work Order No.}'=${LOCAL_PART} and<br>
> queue!='Water Invoices'" | sed -e s+^.*/++)<br>
><br>
> # validate $parent here; exit 1 if not found<br>
> if [[ -z $parent ]] ; then<br>
> echo "Work Order ${LOCAL_PART} not found"<br>
> exit 1<br>
> fi<br>
><br>
> # exit 1 if multiple tickets found<br>
> if [ `echo $parent | wc | awk '{print $2}'` -gt 1 ] ; then<br>
> echo "Multiple tickets with Work Order ${LOCAL_PART} found"<br>
> echo "ticket numbers are " `echo $parent | sed s+ticket/++g`<br>
> exit 1<br>
> fi<br>
><br>
> # Now link ticket<br>
> /opt/rt4/bin/rt link ${ticket} memberof ${parent}<br>
><br>
> # and set custom fields<br>
> /opt/rt4/bin/rt edit ticket/${ticket} set 'CF.{contractor}'="${contractor}"<br>
> /opt/rt4/bin/rt edit ticket/${ticket} set 'CF.{amount}'="${amount}"<br>
><br>
> export EXTENSION=${ticket}<br>
> cat $t | /opt/rt4/bin/rt-mailgate --action comment --queue Invoices<br>
> --extension ticket --url <a href="http://rt.subutil.com" target="_blank">http://rt.subutil.com</a><br>
><br>
><br>
> --<br>
> Pain is temporary. It may last a minute, or an hour, or a day, or a year,<br>
> but eventually it will subside and something else will take its place. If<br>
> I quit, however, it lasts forever.<br>
><br>
> --------<br>
> RT Training Sessions (<a href="http://bestpractical.com/services/training.html" target="_blank">http://bestpractical.com/services/training.html</a>)<br>
> * Barcelona, Spain November 28 & 29, 2011<br>
</div></div><br>--------<br>
RT Training Sessions (<a href="http://bestpractical.com/services/training.html" target="_blank">http://bestpractical.com/services/training.html</a>)<br>
* Barcelona, Spain — November 28 & 29, 2011<br></blockquote></div><br></div>