[rt-users] Shredder API questions

Ruslan Zakirov ruslan.zakirov at gmail.com
Sun Jan 7 08:46:27 EST 2007


I thought it's clear enough from POD that interface is PutObject(
Object => $user_obj );

On 1/7/07, Mathew Snyder <theillien at yahoo.com> wrote:
> Ruslan Zakirov wrote:
> > On 12/30/06, Mathew Snyder <theillien at yahoo.com> wrote:
> >> I'm rewriting a script that will eliminate all spam users accrued over
> >> the
> >> course of a day.  Presently, it is using the least efficient way of
> >> executing
> >> the wipeout by performing a system call to rtx-shredder.  I would
> >> prefer to run
> >> the wipeout by way of the Shredder API.  I'm guessing along the lines
> >> of this:
> >>
> >> # load plugin by preformatted string
> >> my $pluginString =
> >> "'Users=status,any;email,$email;replace_relations,Nobody'";
> >> my $plugin = new RTx::Shredder::Plugin;
> >> my( $status, $msg ) = $plugin->LoadByString( $pluginString );
> >> unless( $status ) {
> >>     print STDERR "Couldn't load plugin: $msg\n";
> >>     exit(1);
> >>     }
> >> }
> >>
> >> Another question is in regards to the sql dump.  I've looked at
> >> rtx-shredder and
> >> have seen referrence to the SetFile method but haven't seen anything
> >> about the
> >> DumpSQl method that is mentioned in Shredder.pm.  Is this automatically
> >> accounted for when if I use my ($fname, $fh) = $shredder-SetFile;?
> >>
> >> The portion of my script this relates to is below.
> >>
> >> <snip>
> >> foreach my $email (sort(@emails)){
> >>         print $email . "\n";
> >> }
> >>
> >> print "\nDelete the email addresses from the RT database [y/N]: ";
> >> chomp($ans = <STDIN>);
> >>
> >> if ($ans =~ m/^(y|yes)$/i){
> >>         my $email;
> >>         foreach $email (@emails){
> >> #       system "/usr/local/rt-3.6.1/local/sbin/rtx-shredder --force
> >> --plugin \
> >> 'Users=status,any;email,$email;replace_relations,Nobody'";
> >>         # load plugin by preformatted string
> >>                 my $pluginString = \
> >> "'Users=status,any;email,$email;replace_relations,Nobody'";
> >>                 my $plugin = new RTx::Shredder::Plugin;
> >>                 my( $status, $msg ) = $plugin->LoadByString(
> >> $pluginString );
> >>                 unless( $status ) {
> >>                         print STDERR "Couldn't load plugin: $msg\n";
> >>                         exit(1);
> >>                 }
> >>         }
> >> }
> >> else{
> >>         exit;
> >> }
> >> </snip>
> >>
> >> One problem I can already see with the above snippet is that Shredder
> >> is called
> >> seperately for each email address.  How do I set this up to run as one
> >> continuous execution for the entire array of addresses?
> > You can use $shredder->PutObject and put sever users' objects into
> > shredder and then $shredder->WipeoutAll.
> >
> I've tried
> foreach my $email (@emails) {
>         $shredder->PutObject (User => $email);
> }
>
> $shredder->PutObject (User::LoadByEmail => $email);
> $shredder->PutObject (RT::User::LoadByEmail => $email);
> and
> $shredder->PutObject ($email);
>
> I'm getting
> Odd number of elements in anonymous hash at
> /usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, <STDIN> line 1.
> Use of uninitialized value in anonymous hash ({}) at
> /usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, <STDIN> line 1.
> Odd number of elements in hash assignment at
> /usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 287, <STDIN> line 1.
> Unsupported type '(undef)'
>
> Trace begun at /usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 290
> RTx::Shredder::PutObject('RTx::Shredder=HASH(0xa283e64)',
> 'kusare.com at focalsecurity.com') called at delete_spam_users.pl line 65
>
> I looked at line 177 in Shredder and couldn't figure out what I was looking at.
>  I also looked at the perldoc for Shredder.pm, User.pm, Users.pm and Record.pm.
>
> I don't know what I'm missing.
>
> Mathew
>
>


-- 
Best regards, Ruslan.



More information about the rt-users mailing list