Page 1 of 1

Howto: Send newline via Prowl Perl API

Posted: Thu Jul 11, 2013 9:20 am
by MaxWinterstein
Hi,

i am setting up Prowl to notify me depending on the status of my nagios system. To accomplish this is use the Perl API from the official website. Sadly there is no support for \n newline format. i is encoded as an backslash and an n so it is not shown correct right in the app.

So this is my 5 minutes noob perl hack to encode the \n (string) into a real \n (char)

Code: Select all

diff prowlOriginal.pl prowlWithNewlineSupport.pl
70c70,71
< $options{'notification'} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
---
> $options{'notification'} =~ s/(\\n)/\n/g; # Encode \n correct - max 11.07.2013
> $options{'notification'} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/eg;


Hope somebody finds it usefull :)

Greetings
Max