<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Issue with ScriptExecute Processor in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205261#M71429</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/11035/sanazjanbakhsh.html" nodeid="11035" target="_blank"&gt;@Sanaz Janbakhsh&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Use the below script to add the encoded payload attribute to the flow file.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Script:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;import base64  
flowFile = session.get() 
if flowFile is not None: 
  myAttr = flowFile.getAttribute('payload') 
  out=base64.b64decode(myAttr) 
  out1=base64.b16encode(out) 
  flowFile = session.putAttribute( flowFile, 'attr', out1)
  session.transfer(flowFile, REL_SUCCESS)&lt;/PRE&gt;&lt;P&gt;diff between &lt;STRONG&gt;'out1',out1&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;flowFile = session.putAttribute( flowFile, 'attr', 'out1') //script adds attribute attr value as out1(because out1 is in single quotes). if you want to add the out1 actual encoded value we need to use out1 without single quotes.&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Here is an example i tried:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;i am having &lt;STRONG&gt;payload&lt;/STRONG&gt; attribute value as &lt;STRONG&gt;asdf&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Python shell output:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&amp;gt;&amp;gt;&amp;gt; import base64
&amp;gt;&amp;gt;&amp;gt; out=base64.b64decode('asdf')
&amp;gt;&amp;gt;&amp;gt; out1=base64.b16encode(out)
&amp;gt;&amp;gt;&amp;gt; print out1
6AC75F&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;NiFi Script:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="42673-executescript.png" style="width: 655px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17114i0B5E9506AEBE4FE1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="42673-executescript.png" alt="42673-executescript.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Output:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="42674-executescript-op.png" style="width: 300px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17115iD3573389C56F9706/image-size/medium?v=v2&amp;amp;px=400" role="button" title="42674-executescript-op.png" alt="42674-executescript-op.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see above &lt;STRONG&gt;payload &lt;/STRONG&gt;attribute value is &lt;STRONG&gt;asdf &lt;/STRONG&gt;and script &lt;STRONG&gt;attr&lt;/STRONG&gt; value is &lt;STRONG&gt;6AC75F&lt;/STRONG&gt;, &lt;STRONG&gt;Python shell output and script outputs are matching.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Aug 2019 04:52:24 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2019-08-18T04:52:24Z</dc:date>
    <item>
      <title>Issue with ScriptExecute Processor</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205258#M71426</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;I am stuck with the ScriptExecute process.I am running a small code to see how it works.&lt;/P&gt;&lt;P&gt;flowFile = session.get()
if flowFile is not None :
 myAttr = flowFile.getAttribute('payload')
        session.transfer(flowFile, REL_SUCCESS)&lt;/P&gt;&lt;P&gt;But i get the attached error. It would be great if someone help me.&lt;/P&gt;&lt;P&gt;SJ&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 22:53:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205258#M71426</guid>
      <dc:creator>Sanaz_janbakhsh</dc:creator>
      <dc:date>2017-11-17T22:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with ScriptExecute Processor</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205259#M71427</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/11035/sanazjanbakhsh.html" nodeid="11035" target="_blank"&gt;@Sanaz Janbakhsh&lt;/A&gt;
&lt;/P&gt;&lt;P&gt;Try to run the below script&lt;/P&gt;&lt;PRE&gt;flowFile = session.get() 
if flowFile is not None: 
  myAttr = flowFile.getAttribute('payload')
  session.transfer(flowFile, REL_SUCCESS)&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;ExecuteScript Configs:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="42671-executescript.png" style="width: 1745px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17116iB714550BAF8A9C62/image-size/medium?v=v2&amp;amp;px=400" role="button" title="42671-executescript.png" alt="42671-executescript.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In addition if you want to add an attribute,&lt;/P&gt;&lt;P&gt;Below script adding attribute named &lt;STRONG&gt;attr&lt;/STRONG&gt; value &lt;STRONG&gt;1&lt;/STRONG&gt; to the flowfile.&lt;/P&gt;&lt;PRE&gt;flowFile = session.get() 
if flowFile is not None: 
  myAttr = flowFile.getAttribute('payload')
  flowFile = session.putAttribute( flowFile, 'attr', '1' ) //adding attribute attr with value 1 to the flowfile
  session.transfer(flowFile, REL_SUCCESS)&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Aug 2019 04:52:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205259#M71427</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T04:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with ScriptExecute Processor</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205260#M71428</link>
      <description>&lt;P&gt;Hi Shu,&lt;/P&gt;&lt;P&gt;Thanks alot for your help always. That works&lt;/P&gt;&lt;P&gt;I made the script to decode the payload and would like to add it to flowfile as you mentioned  &lt;/P&gt;&lt;P&gt;flowFile = session.get() 
if flowFile is not None: 
  myAttr = flowFile.getAttribute('payload')
out=base64.b64decode(myAttr)
out1=base64.b16encode(out)
flowFile = session.putAttribute( flowFile, 'attr', 'out1' ) 
  session.transfer(flowFile, REL_SUCCESS)&lt;/P&gt;&lt;P&gt;Got the attached error. Any thoughts please.&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/43630-1.png"&gt;1.png&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2017 01:44:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205260#M71428</guid>
      <dc:creator>Sanaz_janbakhsh</dc:creator>
      <dc:date>2017-11-18T01:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with ScriptExecute Processor</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205261#M71429</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/11035/sanazjanbakhsh.html" nodeid="11035" target="_blank"&gt;@Sanaz Janbakhsh&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Use the below script to add the encoded payload attribute to the flow file.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Script:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;import base64  
flowFile = session.get() 
if flowFile is not None: 
  myAttr = flowFile.getAttribute('payload') 
  out=base64.b64decode(myAttr) 
  out1=base64.b16encode(out) 
  flowFile = session.putAttribute( flowFile, 'attr', out1)
  session.transfer(flowFile, REL_SUCCESS)&lt;/PRE&gt;&lt;P&gt;diff between &lt;STRONG&gt;'out1',out1&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;flowFile = session.putAttribute( flowFile, 'attr', 'out1') //script adds attribute attr value as out1(because out1 is in single quotes). if you want to add the out1 actual encoded value we need to use out1 without single quotes.&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Here is an example i tried:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;i am having &lt;STRONG&gt;payload&lt;/STRONG&gt; attribute value as &lt;STRONG&gt;asdf&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Python shell output:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&amp;gt;&amp;gt;&amp;gt; import base64
&amp;gt;&amp;gt;&amp;gt; out=base64.b64decode('asdf')
&amp;gt;&amp;gt;&amp;gt; out1=base64.b16encode(out)
&amp;gt;&amp;gt;&amp;gt; print out1
6AC75F&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;NiFi Script:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="42673-executescript.png" style="width: 655px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17114i0B5E9506AEBE4FE1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="42673-executescript.png" alt="42673-executescript.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Output:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="42674-executescript-op.png" style="width: 300px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17115iD3573389C56F9706/image-size/medium?v=v2&amp;amp;px=400" role="button" title="42674-executescript-op.png" alt="42674-executescript-op.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see above &lt;STRONG&gt;payload &lt;/STRONG&gt;attribute value is &lt;STRONG&gt;asdf &lt;/STRONG&gt;and script &lt;STRONG&gt;attr&lt;/STRONG&gt; value is &lt;STRONG&gt;6AC75F&lt;/STRONG&gt;, &lt;STRONG&gt;Python shell output and script outputs are matching.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 04:52:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205261#M71429</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T04:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with ScriptExecute Processor</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205262#M71430</link>
      <description>&lt;P&gt;Thanks shu, really helpful. &lt;/P&gt;</description>
      <pubDate>Sun, 19 Nov 2017 09:21:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Issue-with-ScriptExecute-Processor/m-p/205262#M71430</guid>
      <dc:creator>Sanaz_janbakhsh</dc:creator>
      <dc:date>2017-11-19T09:21:55Z</dc:date>
    </item>
  </channel>
</rss>

