[Rt-devel] Reporting tickets from a script, getting ticket ID back?
Petter Reinholdtsen
pere at hungry.com
Tue Aug 2 10:33:07 EDT 2005
I'm currently investigating how I can generate RT tickets from a
script, and let the script keep track of the ticket ID of already
reported issues.
I found a thread from 2001 giving an example, and have implemented
this.
<URL:http://lists.bestpractical.com/pipermail/rt-devel/2001-April/001108.html>.
Is this still the best way to do this?
The script I have at the moment work, but it seem rather crude to call
rt-mailgate in debug mode just to get the ticket-ID out. Is there no
simpler way? Perhaps rt-mailgate should get some extra functionality
to allow it to print the ticket-ID to stdout on request?
This is my current proof-of-concept script:
#!/usr/bin/perl
use strict;
use warnings;
use File::Temp qw(tempfile);
my $rturl = "https://rt-dev.uio.no/";
my $mailgate = "/local/bin/rt-mailgate";
sub new_ticket {
my ($queue, $from, $subject, $body) = @_;
my ($fh, $filename) = tempfile("rt-reportXXXXX", DIR => "/tmp");
print $fh "From: $from\n";
print $fh "Subject: $subject\n";
print $fh "\n";
print $fh "$body\n";
open(MAILGATE, "$mailgate --action correspond --queue $queue --url $rturl --debug < $filename 2>&1 |") || die "Unable to start $mailgate";
my $id;
# okTicket: 1728Queue: generalOwner: NobodyStatus: newSubject: TestingRequestor: pere at hungry.com at /site/rt3/bin/rt-mailgate line 108, <> chunk 1.
while (<MAILGATE>) {
chomp;
$id = $1 if m/Ticket: (.+)Queue:/;
}
close MAILGATE;
close $fh;
unlink $filename;
return $id;
}
my $queue = "general";
my $from = "pere\@hungry.com";
my $subject = "testing testing";
my $body = "testing more";
my $id = new_ticket($queue, $from, $subject, $body);
print "ID: $id\n";
exit 0;
More information about the Rt-devel
mailing list