Here attached the quick and dirty script that I've implemented... obviously
it lacks on security, file & disk usage, performance, syntax and comments
(and anything else ... :D ) but it is a skel to start with for anyone
interested:

[o...@otrsbox:/opt/otrs/bin]# cat crbugfix.sh
#!/bin/bash

TICKETNUMBER=$1
TICKETID=$2

. /etc/profile

#echo $1 $2 > /tmp/arguments

mysql -r --user=otrs --password=xxxx otrs <<EOF > /tmp/tempo
select a_body from article where ticket_id = ${TICKETID};
EOF


CR=`cat /tmp/tempo | grep "CR implemented" | awk -F\: '{print $2}'`
BF=`cat /tmp/tempo | grep "Bug solved" | awk -F\: '{print $2}'`

#echo ${CR} ${BF} > /tmp/crbf

PREPEND="update ticket set "
POSTPEND=" where id = ${TICKETID};"

if [ $CR = 'n.a.' ]; then
   if [ $BF = 'n.a.' ]; then
      exit
   else
      PREPEND=${PREPEND}" freekey8 = 'DEFECT',  freetext8 = '"${BF}"'"
   fi
else
   PREPEND=${PREPEND}" freekey7 = 'CR', freetext7 = '"${CR}"'"
   if [ $BF = 'n.a.' ]; then
      echo do nothing > /dev/null
   else
      PREPEND=${PREPEND}" , freekey8 = 'DEFECT' , freetext8 = '"${BF}"'"
   fi

fi

UPDATE=${PREPEND}${POSTPEND}

#echo ${UPDATE} > /tmp/update


mysql --user=otrs --password=xxxx otrs <<EOF
${UPDATE}
EOF


this has been tested successfully as a job lauched by the genericagent as
/opt/otrs/bin/crbugfix.sh.

Ciao.

MV

On Mon, Nov 23, 2009 at 4:10 AM, Marco Vannini <[email protected]>wrote:

> I've to rectify myself... CMD space in GenericAgent is more then enough for
> me because this mail goes to a generic queue and I just have to classify
> them. so, with the same criteria used in GA I can execute a script where it
> takes ticket_id (ARG[1]) and goes in article table with a batch select, it
> parse what I need and then, with the same ticket_id I make an update...
>
> So simple ... I'm so lazy...I'm going to try this.
>
> ciao,
>
> MV
>
>
>
>
> On Mon, Nov 23, 2009 at 12:43 AM, Marco Vannini 
> <[email protected]>wrote:
>
>> Yes it might be, I thought that a trigger could be faster end easiest and
>> would not impact the normal and clean flow that PostMasterMailbox
>> implements. I was thinking at a script that could be executed by the
>> GenericAgent too but I cannot see how having just ARG[0] and ARG[1] that I
>> think they are not enougth for my job. So, probably I'll go through a
>> fetchmail/procmail solution that I think it's similar to what you told me.
>>
>> Thank you very mutch.
>>
>> cheers.
>>
>> MV
>>
>> On Sun, Nov 22, 2009 at 11:54 PM, James Morgan <
>> [email protected]> wrote:
>>
>>>  I did something similar to this with RT and OTRS.  There’s a department
>>> here that uses RT and we use OTRS, so I wrote a script that can accept the
>>> piped output from sendmail (as an alias), parse the message subject (which
>>> had the RT number in it) and add the RT number to one of the FreeText
>>> fields.  It also did a MySQL lookup on the ticket table to work out which
>>> ticket number in OTRS was correct for that RT number and then modified the
>>> subject line of the message to suit (added [Ticket#...] because RT strips it
>>> out).
>>>
>>>
>>>
>>> I suggest it might be a decent option for you.
>>>
>>>
>>>
>>> *From:* [email protected] [mailto:[email protected]] *On Behalf
>>> Of *Marco Vannini
>>> *Sent:* Monday, 23 November 2009 9:36 AM
>>>
>>> *To:* User questions and discussions about OTRS.
>>> *Subject:* Re: [otrs] freefield autofill
>>>
>>>
>>>
>>> yes, it should be something like this.
>>>
>>>
>>>
>>> ie, this is the incoming mail
>>>
>>>
>>>
>>> from: ConfigurationManager
>>>
>>> to: deployment, otrs
>>>
>>> Subject: REV-EBIS version REV-EBIS_209.0.6.B1_IT Available for Test
>>> Environment
>>>
>>> Body:
>>>
>>> Availability in System Test environment.
>>>
>>>  Release REV-EBIS version REV-EBIS_209.0.6.B1_IT  available for System
>>> Test environment on the Italian StarTeam server
>>>
>>>  Project:        Business_Intelligence
>>>
>>>  View:           REV-EBIS_209.0.6.B1_IT
>>>
>>>  CR implemented: n.a.
>>>
>>>  Bug Solved:     75948;76004
>>>
>>>
>>>
>>> for the last two row I would like to get (for CR) n.a (or the values that
>>> could be present) and (for Bug Solved) 75948;76004 and populate freetext7
>>> and freetext8 respectively.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Sun, Nov 22, 2009 at 11:25 PM, James Morgan <
>>> [email protected]> wrote:
>>>
>>> Sorry, I don’t understand the request.  Are you wanting to parse the
>>> incoming message and then set FreeText fields accordingly?
>>>
>>>
>>>
>>> *From:* [email protected] [mailto:[email protected]] *On Behalf
>>> Of *Marco Vannini
>>> *Sent:* Saturday, 21 November 2009 2:43 AM
>>> *To:* User questions and discussions about OTRS.
>>> *Subject:* [otrs] freefield autofill
>>>
>>>
>>>
>>> Hi all,
>>>
>>>
>>>
>>> Is there anyone that has an freefield autofiller just ready and
>>> modifiable ? I mean something like a mysql trigger or something else that
>>> parse incoming mail (so insert into) and take values and update the same
>>> record ?
>>>
>>>
>>>
>>> thanks in advance.
>>>
>>>
>>>
>>> MV
>>>
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> OTRS mailing list: otrs - Webpage: http://otrs.org/
>>> Archive: http://lists.otrs.org/pipermail/otrs
>>> To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs
>>>
>>> NEW! ENTERPRISE SUBSCRIPTION - Get more information NOW!
>>> http://www.otrs.com/en/support/enterprise-subscription/
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> OTRS mailing list: otrs - Webpage: http://otrs.org/
>>> Archive: http://lists.otrs.org/pipermail/otrs
>>> To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs
>>>
>>> NEW! ENTERPRISE SUBSCRIPTION - Get more information NOW!
>>> http://www.otrs.com/en/support/enterprise-subscription/
>>>
>>
>>
>
---------------------------------------------------------------------
OTRS mailing list: otrs - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs

NEW! ENTERPRISE SUBSCRIPTION - Get more information NOW!
http://www.otrs.com/en/support/enterprise-subscription/

Reply via email to