Fwd: [rt-users] Execute Arbitrary Perl Script on resolve
Michael Grubb
mgrubb at fifthvision.net
Thu May 30 15:23:13 EDT 2002
Well Put.
Anyway if you *REALLY* want to just execute external perl code you could do
something like this:
***WARNING****
This is untested code.
I just slapped it together.
I know that the principals behind it work because I've done this before but as
for making sure that RT does it properly is anybody's guess =]
Sure you could use the system function to execute a new perl interpreter but I
liked this solution a little better.
Also I don't know how well this will scale so if you have lots of tickets in a
short amount of time that this will act on I don't know how this will do.
Any way. As it is... Merry Christmas.
-M
package RT::Action::ExecExternal;
require RT::Action::Generic;
@ISA=qw(RT::Action::Generic);
#Do what we need to do and send it out.
#What does this type of Action does
our $queue = undef;
our $prog_txt = undef;
# {{{ sub Describe
sub Describe {
my $self = shift;
return (ref $self . " will execute arbritrary perl code\n");
}
# }}}
# {{{ sub Prepare
sub Prepare {
my $self = shift;
open(EXTPRG, "<" . $self->Argument()) or return 0;
while(<EXTPRG>) { $prog_txt .= $_ }
close(EXTPRG) or return 0;
return 1;
}
# }}}
sub Commit {
my $self = shift;
eval $prog_txt;
$RT::Logger->debug($@ ? $@ : "Executed External App:\n$prog_txt\n");
return !$@;
}
# Applicability checked in Commit.
# {{{ sub IsApplicable
sub IsApplicable {
my $self = shift;
1;
return 1;
}
# }}}
1;
On Thursday 30 May 2002 12:17, Robin Lee Powell wrote:
> On Thu, May 30, 2002 at 09:43:54AM -0700, Will Doherty wrote:
> > Anyway, there seem to be a lot of actions pre-defined... we are trying
> > to figure out which one would be best to simply execute an external
> > Perl script.
>
> You seem to be missing the point:
>
> A ScripAction *IS* an arbitrary perl script.
>
> Make a new one.
>
> -Robin
More information about the rt-users
mailing list