[rt-users] Moving attachments from DB to disk...

Otmar Lendl ol at bofh.priv.at
Mon Aug 25 11:23:41 EDT 2008


On 2008/08/25 16:08, Jerrad Pierce <jpierce at cambridgeenergyalliance.org> wrote:
> Alas, no. When I last I asked I was told it was a design feature. But it
> does seem mighty useful,
> as it would allow for OCR and indexing of attachments. I'd planned on
> attempting this once I got the more important parts of our setup functional.

I'm using the following perl script to get a pgp-encrypted attachment
from a ticket to the local disk and decrypt it. If you want to do
OCR, then you probably want other mime-types, but this should give
you some ideas.


#!/usr/bin/perl -w
#
# Otmar Lendl <lendl at cert.at>
#
# Get encrypted file from Ticket and decrypt it
#

my $t = shift;

die "Usage: $0 ticketnum" unless ($t =~ /^\d+$/);

my $att = `rt show ticket/$t/attachments`;

foreach (split(/\n/,$att)) {
# 621: parsed_logs.zip.asc (application/pgp-encrypted / 358.4k),
#	print "Got $_\n";
	if (/\s(\d+):\s([\w.]+)\s\(application\/pgp-encrypted/) {
		my $fn = $2;
		my $a = $1;
		if ( -e $fn ) {
			print STDERR "$fn exists, skipping\n";
		} else {
			system("rt show ticket/$t/attachments/$a/content > $fn");
			system("gpg $fn");
		}
	}
}


/ol
-- 
-=-  Otmar Lendl  --  ol at bofh.priv.at  -=-



More information about the rt-users mailing list