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