Hi Ibrahim,

I think this is a question you should address to the users mailing list as
it is more a use case question.

Anyway, once you get your files after the combination of ListSFTP and
FetchSFTP processors, your flow files will have an attribute 'filename'
with the name of your files. Then you can use an UpdateAttribute processor
to create one attribute per argument you want to pass to your
ExecuteStreamCommand processor. Using getDelimitedField function [1] from
the expression language you should easily get what you want by adding new
properties for each argument you want to extract:

arg1 => ${filename:getDelimitedField(1,'.')}
arg2 => ${filename:getDelimitedField(2,'.')}
arg3 => ${filename:getDelimitedField(3,'.')}
arg4 => ${filename:getDelimitedField(4,'.')}
arg5 =>
${filename:getDelimitedField(5,'.'):append('.'):append(${filename:getDelimitedField(6,'.')})}
arg6 => ${filename:getDelimitedField(7,'.')}

Then you can reference these attributes in your next processors as command
arguments since the property supports expression language.

[1]
https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#getdelimitedfield

Hope this helps.
Pierre.



2016-10-28 2:27 GMT+02:00 Hameed, Ibrahim <[email protected]>:

> Hi Dev community
>
>
>
> I have the below use-case which I am trying to achieve it through NIFI
> processor.
>
>
>
> I have a regular expression format for a file which will be picking up
> through “LIST SFTP processor “  with File filter regex :
> "^(ACRS)[.](COF)[.](FRAUD)[.](PROD)[.](.*)[.](CCOD.+)"
>
>
>
> Based on the above regex, it will kick of a script lets say : echocmd.sh.
>
>
>
> But I want to pass 6 arguments to the above script, arguments are
> calculated from the filename.
>
>
>
> File name : CRS.COF.Fraud.prod.20161024030233.CommMonetaryActivity_Daily.
> CCOD
>
>
>
> Please find my arguments :
>
>
>
> Arg 1 : awk -F"." '{print $1}' filename : CRS
>
> Arg 2 : awk -F"." '{print $2}' filename : COF
>
> Arg 3 : awk -F"." '{print $3}' filename : Fraud
>
> Arg 4 : awk -F"." '{print $4}' filename : prod
>
> Arg 5 : 20161024030233.CommMonetaryActivity_Daily
>
> Arg 6 :grep -P -o 'CCOD' filename :  CCOD
>
>
>
> My question :
>
>
>
> I want to pass the above arguments to my execute stream command processor,
> can you provide me some guidance in achieving this.
>
>
>
> r
>
>
>
>
>
> *Ibrahim Hameed*
> *Data Movement & Engineering*
>
> 804.297.8865
>
> [email protected]
>
> “Talent Wins Games, but Teamwork and Intelligence Win Championships”.
>
>
>
> ------------------------------
>
> The information contained in this e-mail is confidential and/or
> proprietary to Capital One and/or its affiliates and may only be used
> solely in performance of work or services for Capital One. The information
> transmitted herewith is intended only for use by the individual or entity
> to which it is addressed. If the reader of this message is not the intended
> recipient, you are hereby notified that any review, retransmission,
> dissemination, distribution, copying or other use of, or taking of any
> action in reliance upon this information is strictly prohibited. If you
> have received this communication in error, please contact the sender and
> delete the material from your computer.
>

Reply via email to