[rt-users] how to access content for an attachment in scrip?

Mauricio Tavares raubvogel at gmail.com
Thu Jul 7 00:24:16 EDT 2011


On 07/06/2011 08:52 PM, John Alberts wrote:
> I've found several unanswered questions in the mail list archives with
> similar questions about looping through attachments.
> I saw several times it suggested to loop through attachments using
> something like
> while ( my $AttachObj = $self->TransactionObj->Attachments->Next ) {
> # do something with $AttachObj
> }
>
> This code doesn't work because ->Next doesn't exist for the Attachment
> object. Is there any other way to do this? Sorry if this is incredibly
> simple to do. I'm not familiar with Perl and try to poke around and see
> if I can figure it out.
>
	Take a look at the code I put in my question "Faking 
{$Transaction->Content()}." I still do not have an answer to my own 
question but it might be useful to you: see what I've done to locate all 
attachments. The multipart/mixed part AFAIK is just the list of all the 
other attachments or something like that. In other words, ignore it. 
About env-vars.txt, is it a plain text file or, say, a Windows one (with 
CRLF)? If that is the case, you might be able to select it (see the if 
statements I did for ideas) and print it out.


>
> ----------
>
> John Alberts
>
> Cloud Optimization Engineer
>
> Ex Libris (USA) Inc.
> 1350 E. Touhy Ave. Suite 200 East
> Des Plaines, IL 60018
> Phone: 1-219-979-6560
>
> *Follow Ex Libris on Twitter: @exlibrisgroup
> <http://twitter.com/ExLibrisGroup>*
>
>
> From: John Alberts <john.alberts at exlibrisgroup.com
> <mailto:john.alberts at exlibrisgroup.com>>
> Date: Wed, 6 Jul 2011 22:01:47 +0000
> To: "rt-users at lists.bestpractical.com
> <mailto:rt-users at lists.bestpractical.com>"
> <rt-users at lists.bestpractical.com <mailto:rt-users at lists.bestpractical.com>>
> Subject: Re: [rt-users] how to access content for an attachment in scrip?
>
> Using the rt console, I can see that there are actually 3 attachments,
> even though the I only sent one and the web ui only shows 1, so I'm sure
> the problem is that I'm selecting the wrong attachment.
>
> Here's what I see from the console.
> ./rt show 2075/attachments
> 19671: (Unnamed) (multipart/mixed / 0b),
> 19672: (Unnamed) (text/plain / 305b),
> 19673: env-vars.txt (application/octet-stream / 16.8k)
>
>
> The attachment I would like will always be named env-vars.txt. How can I
> get the contents for the attachment name env-vars.txt?
>
> Thanks
>
> John
>
>
> From: John Alberts <john.alberts at exlibrisgroup.com
> <mailto:john.alberts at exlibrisgroup.com>>
> Date: Wed, 6 Jul 2011 20:06:34 +0000
> To: "rt-users at lists.bestpractical.com
> <mailto:rt-users at lists.bestpractical.com>"
> <rt-users at lists.bestpractical.com <mailto:rt-users at lists.bestpractical.com>>
> Subject: [rt-users] how to access content for an attachment in scrip?
>
> Hi. I'm trying to customize the scrip shown at the bottom of this wiki
> page: http://requesttracker.wikia.com/wiki/AutoCloseOnNagiosRecoveryMessages
>
> I know there is an extension that does merging, but I want to do some
> other things with the Nagios variables I have attached as a plain text
> file to the ticket that Nagios creates in RT.
> The first few lines in the scrip attempt to get the content of an
> attachment and put it in a variable named $content. I suspected that
> this was not working, so I added a debug line to dump the contents of
> $contents and it is empty.
>
> Here is the scrip code.
> my $T_Obj = $self->TicketObj;
> my $AttachObj = $self->TransactionObj->Attachments->First;
> my $content = $AttachObj->Content;
> $RT::Logger->debug("Contents: " . $content);
>
>
> The log output shows:
> [Wed Jul 6 19:47:49 2011] [debug]: Contents: ((eval 3934):4)
>
>
> The attachment is attached to the ticket. I can see it in the web ui and
> can open and read it with no problems. Any idea what I'm doing wrong here?
>
>
> Thanks
>
>
> John
>
>
> -------- 2011 Training: http://bestpractical.com/services/training.html
> -------- 2011 Training: http://bestpractical.com/services/training.html
>
>
>
>
> --------
> 2011 Training: http://bestpractical.com/services/training.html




More information about the rt-users mailing list