nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Koji Kawamura <ijokaruma...@gmail.com>
Subject Re: ReplaceText and special characters
Date Mon, 19 Dec 2016 02:05:50 GMT
Hello,

I did some experiments to see if I can append a carriage return.
GenerateFlowFile generating 10 random bytes, followed by:

1. ReplaceText
  - Replacement Value: SHIFT-ENTER
  - Replacement Strategy: Append
2. ReplaceText
  - Replacement Value: ${literal(''):replaceFirst('','\r')}
  - Replacement Strategy: Append
3. ExecuteStreamCommand
  - Command Arguments: -0;printf;%s\r
  - Command Path: xargs

Results:
- All of above processors (1, 2 and 3) generated flow file containing 11 bytes
- Saved the result flow files, then confirmed bytes with hexdump command:

- #1: SHIFT-ENTER added '0a'
0000000 61 51 ed f1 8f ab be a1 3d 7a 0a
000000b

- #2: '\r' seems working, it added CR '0d'
0000000 61 51 ed f1 8f ab be a1 3d 7a 0d
000000b

- #3: xargs and printf can also add CR '0d'
0000000 61 51 ed f1 8f ab be a1 3d 7a 0d
000000b

>From above experiment result, NiFi Expression Language or printf
command will be able to provide results you wanted. Please let me know
if those are different than your need.

For the 2nd question, usage of GenerateFlowFile, if it does what you
need, I think it's just fine. If specific byte array is needed for
some reason, then I'd do use FetchFlowFile.

Hope this helps.

Thanks,
Koji

On Mon, Dec 19, 2016 at 6:26 AM, ddewaele <ddewaele@gmail.com> wrote:
> Hi,
>
> I need to send a byte sequence to a TCP socket every 10 minutes.
>
> I've setup a GenerateFlowFile processor to generate 1 random byte every 10
> minutes, followed by a replaceText processor that will replace that 1 byte
> with my byte sequence (a string literal).
>
> I can use SHIFT-ENTER in the ReplaceText processor to generate newlines, but
> I would like to generate a carriage return instead of a newline.
>
> Is this possible with the ReplaceText processor ? I've tried using "\r" ,
> "\\r" in both regex and literal mode, but I cannot the carriage return in
> the outgoing flowfile.
>
> Any ideas on how to do this with a standard processor ?
>
> Also, is there another way to generate a flowfile in a CRON-like fashion ? I
> read that the GenerateFlowFile is typically used for load testing, where
> here it used to trigger a CRON based flow. I feel like I'm abusing the
> GenerateFlowFile processor for this.
>
> Thanks.
>
>
>
> --
> View this message in context: http://apache-nifi-users-list.2361937.n4.nabble.com/ReplaceText-and-special-characters-tp480.html
> Sent from the Apache NiFi Users List mailing list archive at Nabble.com.

Mime
View raw message