[rt-users] Ticket Requestors returned as hash ref

Mathew Snyder theillien at yahoo.com
Sun Aug 5 10:04:37 EDT 2007


I'm rewriting a script which will look in our SPAM queue (to which all tickets
deemed to be spam are banished) and run each of the spam "requestors" through
rtx-shredder.  I have it set up to do everything the way I want except it
doesn't work because when asking for $ticket->Requestors I get
RT::Group=HASH(refNumber)

Here's my script:
#!/usr/bin/perl

#############################################
# File:     delete_spam.pl
# Version:  2.0
# Author:   Mathew Snyder
# Date:     August 5, 2007
# Comments: A script to gather up the spam
#                   sent to the Security queue and
#                   eliminate the "users" that
#                       created it.  It then marks those
#                       tickets as deleted for the purpose
#                       of further housecleaning by the
#                       rtx-shredder cronjob.
#############################################

#Set up our environment
use warnings;
use strict;
use lib '/usr/local/rt-3.6.1/lib';
use lib '/usr/local/rt-3.6.1/local/lib';
use lib '/usr/local/lib';
use RT;
use RT::Users;
use RT::Tickets;
use MIME::Lite;
use Reports::Emails;

RT::LoadConfig();
RT::Init();

my @usrID;
my %userID;
my @emails;

my %skipEmails = (
        "ids-tripwire" => undef,
        "tripwire"         => undef,
        "security"         => undef
);

my $users = new RT::Users(RT::SystemUser);
$users->LimitToPrivileged;

while ( my $user = $users->Next ) {
        next if $user->Name eq 'root';
        $skipEmails{$user->EmailAddress} = undef;
}

foreach my $key (@usrID) {
        $skipEmails{$key} = undef;
}

my $tix = new RT::Tickets(RT::SystemUser);
$tix->FromSQL('Queue = "SPAM"');

while (my $ticket = $tix->Next) {
        print $ticket->Requestors . "\n";
    if (exists($skipEmails{$ticket->Requestors}) or $ticket->Requestors == "") {
                next;
        }
        else {
                push @emails, $ticket->Requestors;
        }
#       $ticket->SetStatus("deleted");
}

#my $count = 0;
#foreach my $email (@emails) {
#
system("/usr/local/rt-3.6.1/local/sbin/rtx-shredder","--force","--plugin","Users=status,any;email,$email;replace_relations,Nobody");
#       $count++;
#}

#my $emailTo      = "msnyder\@servervault.com";
#my $emailFrom    = "RT";
#my $emailSubj    = "RT Spam Removal";
#my $emailMsg     = "The spam removal script has completed and has removed
$count spam created users";

#my $fullEmail    = new MIME::Lite(From    => $emailFrom,
#                                  To      => $emailTo,
#                                  Subject => $emailSubj,
#                                  Data    => $emailMsg,
#);

#$fullEmail->send("sendmail", "/usr/sbin/sendmail -t");
#unlink glob "*.sql";

exit;

Where am I going wrong with this?  How do I set it up to get those actual email
addresses instead of an RT::Group hash ref?

Thanks,
Mathew
-- 
Keep up with me and what I'm up to: http://theillien.blogspot.com



More information about the rt-users mailing list