Re[2]: [rt-users] Ticket Requestors returned as hash ref

Viktor svitter at list.ru
Sun Aug 5 16:40:31 EDT 2007


The first thought is, try to use Data::Dumper and to output Dumper( $ticket->Requestors ) in the right place.
Thus you could see key/value pairs.
Either key or value in each pair is probably an object, i.e. a blessed reference, so the output might be quite bulky...


-----Original Message-----
From: Mathew Snyder <theillien at yahoo.com>
To: RT Users <rt-users at lists.bestpractical.com>
Date: Sun, 05 Aug 2007 15:10:49 -0400
Subject: Re: [rt-users] Ticket Requestors returned as hash ref

> 
> I've been trying to figure out how to dereference the hash but I haven't been
> successful.
> 
> Any thoughts?
> 
> Keep up with me and what I'm up to: http://theillien.blogspot.com
> 
> 
> Mathew Snyder wrote:
> > 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
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
> 
> 
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
> Buy a copy at http://rtbook.bestpractical.com
> 



More information about the rt-users mailing list