#!/usr/local/bin/perl # RT3 escalation script # # This script escalates tickets priorties using the inbuilt RT code. # # Tweaked version of RT2 script by T.D.Bishop@kent.ac.uk, July 2003. ### Configuration # Queue to operate on my($queuename) = 'cs-syshelp'; # Location of RT3's libs use lib ("/usr/local/packages/rt/lib", "/usr/local/packages/rt/local/lib"); ### Code use strict; use Carp; # Pull in the RT stuff package RT; use RT::Interface::CLI qw(CleanEnv GetCurrentUser GetMessageContent loc); # Clean our the environment CleanEnv(); # Load the RT configuration RT::LoadConfig(); # Initialise RT RT::Init(); # Drop any setgid permissions we might have RT::DropSetGIDPermissions(); use RT::Date; use RT::Tickets; use RT::Action::EscalatePriority; # Load in the queue my $queue = new RT::Queue($RT::SystemUser); $queue->Load($queuename); my $now = new RT::Date($RT::SystemUser); $now->SetToNow(); # Get hold of new and open tickets only my $tickets = new RT::Tickets($RT::SystemUser); $tickets->LimitStatus(VALUE => 'open'); $tickets->LimitStatus(VALUE => 'new'); $tickets->LimitQueue(VALUE => $queue->Id); # Process each ticket while (my $ticket = $tickets->Next) { my $action = new RT::Action::EscalatePriority(TicketObj => $ticket); if ($action->Prepare()) { $action->Commit(); } } # Disconnect before we finish off $RT::Handle->Disconnect(); exit 0;