Shredder API questions

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.

foreach my $email (sort(@emails)){ print $email . "\n"; }

print "\nDelete the email addresses from the RT database [y/N]: ";
chomp($ans = );

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;
}

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?

Any and all help will be greatly appreciated.

Mathew

Mathew Snyder 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.

foreach my $email (sort(@emails)){ print $email . "\n"; }

print "\nDelete the email addresses from the RT database [y/N]: ";
chomp($ans = );

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;
}

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?

Any and all help will be greatly appreciated.

Mathew

Can no one help with this?

Mathew

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.

foreach my $email (sort(@emails)){ print $email . "\n"; }

print "\nDelete the email addresses from the RT database [y/N]: ";
chomp($ans = );

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;
}

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.

Any and all help will be greatly appreciated.

Mathew


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.

Ruslan Zakirov wrote:> On 12/30/06, Mathew Snyder theillien@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.

foreach my $email (sort(@emails)){ print $email . "\n"; }

print "\nDelete the email addresses from the RT database [y/N]: ";
chomp($ans = );

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;
}

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, line 1.
Use of uninitialized value in anonymous hash ({}) at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, line 1.
Odd number of elements in hash assignment at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 287, 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@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

Ruslan Zakirov wrote:> On 12/30/06, Mathew Snyder theillien@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.

foreach my $email (sort(@emails)){ print $email . "\n"; }

print "\nDelete the email addresses from the RT database [y/N]: ";
chomp($ans = );

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;
}

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, line 1.
Use of uninitialized value in anonymous hash ({}) at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, line 1.
Odd number of elements in hash assignment at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 287, 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@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

I thought it’s clear enough from POD that interface is PutObject(
Object => $user_obj );On 1/7/07, Mathew Snyder theillien@yahoo.com wrote:

Ruslan Zakirov wrote:

On 12/30/06, Mathew Snyder theillien@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.

foreach my $email (sort(@emails)){ print $email . "\n"; }

print "\nDelete the email addresses from the RT database [y/N]: ";
chomp($ans = );

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;
}

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, line 1.
Use of uninitialized value in anonymous hash ({}) at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, line 1.
Odd number of elements in hash assignment at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 287, 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@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.

Maybe I’m just not getting it then.

my $shredder; = new RTx::Shredder(RT::SystemUser);
if ($ans =~ m/^(y|yes)$/i){
my $email;
foreach $email (@emails) {
$shredder->PutObject( Object => $email );
}
$shredder->WipeoutAll;
}

Yields

Odd number of elements in anonymous hash at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, line 1.
Use of uninitialized value in anonymous hash ({}) at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, line 1.
Unsupported type ‘vcxhdg645@doramail.com’

Trace begun at /usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 290
RTx::Shredder::PutObject(‘RTx::Shredder=HASH(0xa5e40e4)’, ‘Object’,
‘vcxhdg645@doramail.com’) called at delete_spam_users.pl line 65

Maybe I’m just not getting it then.

my $shredder; = new RTx::Shredder;
if ($ans =~ m/^(y|yes)$/i){
my $email;
foreach $email (@emails) {
my $user = RT::User->new( $RT::SystemUser );
$user->LoadByEmail( $email );
next unless $user->id;
$shredder->PutObject( Object => $user );
}
$shredder->WipeoutAll;
}

Yields

Odd number of elements in anonymous hash at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, line 1.
Use of uninitialized value in anonymous hash ({}) at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, line 1.
Unsupported type ‘vcxhdg645@doramail.com’

Trace begun at /usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 290
RTx::Shredder::PutObject(‘RTx::Shredder=HASH(0xa5e40e4)’, ‘Object’,
‘vcxhdg645@doramail.com’) called at delete_spam_users.pl line 65

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

Ruslan Zakirov 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.

foreach my $email (sort(@emails)){ print $email . "\n"; }

print "\nDelete the email addresses from the RT database [y/N]: ";
chomp($ans = );

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;
}

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, line 1.
Use of uninitialized value in anonymous hash ({}) at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 177, line 1.
Odd number of elements in hash assignment at
/usr/local/rt-3.6.1/local/lib/RTx/Shredder.pm line 287, 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.

Best regards, Ruslan.