<?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: how to pass arguments for shellscript in Nifi for ExecuteProcess in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-pass-arguments-for-shellscript-in-Nifi-for/m-p/226074#M77658</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44497/raajmuthu.html" nodeid="44497" target="_blank"&gt;@Raj ji&lt;/A&gt;
&lt;/P&gt;&lt;P&gt;You can use Execute Process (or) Execute Stream Command processors to pass arguments to the shell script.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Execute Process Processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This processor won't need any upstream connections to trigger the script i.e this processor can run its own based on the schedular.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm having sample script which gets 2 command line arguments and echo output.&lt;/P&gt;&lt;PRE&gt;bash$ cat sample_script.sh
#!/bin/bash
echo "First arg: $1"
echo "Second arg: $2"&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Execution in terminal:-&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;bash$ ./sample_script.sh hello world
First arg: hello
Second arg: world&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;1.Execution in NiFi using ExecuteProcess Processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Command&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;bash&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Command Arguments&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;/tmp/sample_script.sh hello world //here we are triggering the shell script and passing arguments with space &lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Batch Duration
No value set
Redirect Error Stream&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;false&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Argument Delimiter &lt;/P&gt;&lt;PRE&gt;space //by default&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;if Argument Delimiter is &lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;;&lt;/PRE&gt;&lt;P&gt;then command arguments would be&lt;/P&gt;&lt;PRE&gt;/tmp/sample_script.sh;hello;world&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;BR /&gt;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="72431-executeprocess.png" style="width: 1504px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15376i0EBBDF610AD2F00E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72431-executeprocess.png" alt="72431-executeprocess.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Success relation from ExecuteProcess will output the below as content of flowfile&lt;/P&gt;&lt;PRE&gt;First arg: hello
Second arg: world&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;2.Execution in NiFi using ExecuteStreamCommand processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This processor needs some upstream connection to trigger the script.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Flow:-&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="72432-flow.png" style="width: 2132px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15377iE4859145CCBAFD0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72432-flow.png" alt="72432-flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We have used generateflowfile processor as a trigger to ExecuteStreamCommand script&lt;BR /&gt;&lt;STRONG&gt;&lt;U&gt;Generateflowfile 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="72433-gnf.png" style="width: 1707px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15378i6D4C9FD2DB10B277/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72433-gnf.png" alt="72433-gnf.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Added two attributes arg1,arg2 to the flowfile &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;ExecuteStreamCommand processor:-&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="72434-esc.png" style="width: 1490px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15379i9665143E2222C779/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72434-esc.png" alt="72434-esc.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Command Arguments
&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${arg1};${arg2}&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Command Path
&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;/tmp/sample_script.sh&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt; Argument Delimiter
&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;;&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;Now we are using the attributes that added in generateflowfile processor and passing them to the script.&lt;/P&gt;&lt;P&gt;Use the OutputStream relation from ExecuteStreamCommand processor and the output flowfile content would be same&lt;/P&gt;&lt;PRE&gt;First arg: hello
Second arg: world&lt;/PRE&gt;&lt;P&gt;By using these processors you can trigger the shell script and pass the arguments also.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer,&lt;/STRONG&gt; That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
    <pubDate>Sun, 18 Aug 2019 01:29:49 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2019-08-18T01:29:49Z</dc:date>
    <item>
      <title>how to pass arguments for shellscript in Nifi for ExecuteProcess</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-pass-arguments-for-shellscript-in-Nifi-for/m-p/226073#M77657</link>
      <description>&lt;P&gt;I have created a Shellscript and It requires three arguments to be passed . It was working fine till I execute it in a terminal . When I configured using Nifi &lt;STRONG&gt;ExecuteProcess &lt;/STRONG&gt;,nifi is ignoring the arguments . &lt;/P&gt;&lt;P&gt;Example :/tmp/script.sh 1 2 8&lt;/P&gt;&lt;P&gt;Refer the attached image . How can I inform nifi to look at the arguments for shell script.&lt;/P&gt;&lt;P&gt;Or kindly advice me to use anyother processor with detailed steps . Since this is not my strongest point . &lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="71450-ni.png" style="width: 785px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15380iA46926BAA53AF4D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="71450-ni.png" alt="71450-ni.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 01:29:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-pass-arguments-for-shellscript-in-Nifi-for/m-p/226073#M77657</guid>
      <dc:creator>raaj_muthu</dc:creator>
      <dc:date>2019-08-18T01:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to pass arguments for shellscript in Nifi for ExecuteProcess</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-pass-arguments-for-shellscript-in-Nifi-for/m-p/226074#M77658</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44497/raajmuthu.html" nodeid="44497" target="_blank"&gt;@Raj ji&lt;/A&gt;
&lt;/P&gt;&lt;P&gt;You can use Execute Process (or) Execute Stream Command processors to pass arguments to the shell script.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Execute Process Processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This processor won't need any upstream connections to trigger the script i.e this processor can run its own based on the schedular.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm having sample script which gets 2 command line arguments and echo output.&lt;/P&gt;&lt;PRE&gt;bash$ cat sample_script.sh
#!/bin/bash
echo "First arg: $1"
echo "Second arg: $2"&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Execution in terminal:-&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;bash$ ./sample_script.sh hello world
First arg: hello
Second arg: world&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;1.Execution in NiFi using ExecuteProcess Processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Command&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;bash&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Command Arguments&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;/tmp/sample_script.sh hello world //here we are triggering the shell script and passing arguments with space &lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Batch Duration
No value set
Redirect Error Stream&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;false&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Argument Delimiter &lt;/P&gt;&lt;PRE&gt;space //by default&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;if Argument Delimiter is &lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;;&lt;/PRE&gt;&lt;P&gt;then command arguments would be&lt;/P&gt;&lt;PRE&gt;/tmp/sample_script.sh;hello;world&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;BR /&gt;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="72431-executeprocess.png" style="width: 1504px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15376i0EBBDF610AD2F00E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72431-executeprocess.png" alt="72431-executeprocess.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Success relation from ExecuteProcess will output the below as content of flowfile&lt;/P&gt;&lt;PRE&gt;First arg: hello
Second arg: world&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;2.Execution in NiFi using ExecuteStreamCommand processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This processor needs some upstream connection to trigger the script.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Flow:-&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="72432-flow.png" style="width: 2132px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15377iE4859145CCBAFD0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72432-flow.png" alt="72432-flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We have used generateflowfile processor as a trigger to ExecuteStreamCommand script&lt;BR /&gt;&lt;STRONG&gt;&lt;U&gt;Generateflowfile 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="72433-gnf.png" style="width: 1707px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15378i6D4C9FD2DB10B277/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72433-gnf.png" alt="72433-gnf.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Added two attributes arg1,arg2 to the flowfile &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;ExecuteStreamCommand processor:-&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="72434-esc.png" style="width: 1490px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15379i9665143E2222C779/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72434-esc.png" alt="72434-esc.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Command Arguments
&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${arg1};${arg2}&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Command Path
&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;/tmp/sample_script.sh&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt; Argument Delimiter
&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;;&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;Now we are using the attributes that added in generateflowfile processor and passing them to the script.&lt;/P&gt;&lt;P&gt;Use the OutputStream relation from ExecuteStreamCommand processor and the output flowfile content would be same&lt;/P&gt;&lt;PRE&gt;First arg: hello
Second arg: world&lt;/PRE&gt;&lt;P&gt;By using these processors you can trigger the shell script and pass the arguments also.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer,&lt;/STRONG&gt; That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 01:29:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-pass-arguments-for-shellscript-in-Nifi-for/m-p/226074#M77658</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T01:29:49Z</dc:date>
    </item>
  </channel>
</rss>

