Rt shell script: can't create multi-line text in new ticket

Hello!
I’ve been working on a script that checks to see if a ticket exists
for a certain problem, and if not, creates the ticket. I’m using bash
with bin/rt to script this, and have been struggling for a few hours
trying to get it just right. I have all my data in variables, and this
caused me trouble in the beginning… here’s an example:

rt create -t ticket set status=new subject=’${RTSUBJ} ${HOSTNAME}‘
queue=’${RTQUEUE}’ priority=‘5’ text=’${RTMSG}’

Of course, the single quotes caused an issue, and I moved to double
quotes. but then rt was still complaining:

rt: edit: Unrecognised argument ‘text=blah
blah’.

Yes, this is multi-line text… and I figured this was causing the
issue, since removing the “text” parameter allowed a ticket to be
created. I figured a template-based ticket creation would work. When I
noticed the -o option, and went to work with this idea:

rt create -t ticket -o set status=new subject="${RTSUBJ} (${HOSTNAME})“
queue=”${RTQUEUE}" priority=5 | sed -e ‘$d’ > ${RTTMP}
echo “Text: ${RTMSG}” >> ${RTTMP}
cat ${RTTMP} | rt create -t ticket -i

This creates the template, hacks out the "Text: " line, then adds it
again with the appropriate data. However, I get this:

Please resubmit with errors corrected.

Syntax error.

id: ticket/new
Queue: General
Requestor: sbsupdate
Cc:
AdminCc:
Owner:
Status: new
Priority: 5
InitialPriority:
FinalPriority:
TimeEstimated:
Starts: 2008-03-06 05:31:56
Due: 2008-03-06 05:31:56
Text: blah

blah

Not even THIS way likes the multiple lines of text. I suppose I could
really hack it by creating an email header and passing all of this to
rt-mailgate, but that REALLY seems like a hack.

Ideas welcome…

Thank you!

Steve

signature.asc (189 Bytes)

Hello!
I received no replies… perhaps I posted too much info?

So far I’ve tried this a few different ways, and have had no luck
with creating tickets from the command line with multiple lines of text.

This breaks:

rt create -e -t ticket set subject=‘testing’ text='blah

blah
blah’

However, I can do this:

rt create -e -t ticket set subject=‘testing’

then I can comment on it:

rt comment -m 'This is a multi-

line test of text’ 600

…which allows me to use data with multiple lines. Since the original
ticket creation email didn’t have the text with it, I didn’t like this
approach and I decided to hack the rt tool. I’m using rt that installs
with Ubuntu 7.10’s rt3.6-clients package. At line 423, I added the
following:

        elsif (/-m/) {
            vpush( \%set, lc 'text', shift @ARGV);
        }

I’m sorry, I don’t know the correct way to submit a patch with the +'s
an @whatevers, but this is what I did, and now the following works fine:

rt create -e -t ticket set subject=‘testing’ -m ‘blah multi-
line text’

I hope this change (or similar) can make it into the next release.

Also, I just noticed that I cannot place text into custom fields when
using the command line interface. Perhaps I’ll just have to write my own. :slight_smile:

Regards,
Steve

Steve Switzer wrote: