<?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 ExecuteStreamCommand behaves unexpected: pipe breaks in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/ExecuteStreamCommand-behaves-unexpected-pipe-breaks/m-p/368044#M240045</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, I work with spatial data which is in netCDF format. To manipulate and analyze the data I use the NCO toolkit, which consists of a bunch of commands. I run these in the Windows CMD. Though this works fine, it is somewhat slow and cumbersome. Thus I would like to automate this with NiFi. I figured the ExecuteStreamCommand would do the job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The netCDF data comes in via InvokeHTTP (generates a flowfile with ‘Content Type:application/x-netcdf’), and is subsequently fed to the ExecuteStreamCommand. I have it configured as follows &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PieterNiFiHo_0-1681068599810.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37224iCDDC0182D344F5BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PieterNiFiHo_0-1681068599810.png" alt="PieterNiFiHo_0-1681068599810.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;‘ncks’ is the executable command from the NCO Toolkit. This is on my path, such that I am sure NiFi can reach it. When I run the flow as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PieterNiFiHo_1-1681068647274.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37225i02B366C82009B207/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PieterNiFiHo_1-1681068647274.png" alt="PieterNiFiHo_1-1681068647274.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I receive errors on the ExecuteStreamCommand processor. These are as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2023-04-09 20:46:43,879 ERROR [Thread-187] o.a.n.p.standard.ExecuteStreamCommand ExecuteStreamCommand[id=65610950-0187-1000-7ef5-c5d0d5057e63] Failed to write FlowFile to Standard Input Stream&lt;/P&gt;&lt;P&gt;java.io.IOException: De pipe is beëindigd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.io.FileOutputStream.writeBytes(Native Method)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.io.BufferedOutputStream.write(BufferedOutputStream.java:123)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.io.BufferedOutputStream.write(BufferedOutputStream.java:123)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.nifi.stream.io.StreamUtils.copy(StreamUtils.java:36)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.nifi.processors.standard.ExecuteStreamCommand.lambda$readStdoutReadable$1(ExecuteStreamCommand.java:633)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.lang.Thread.run(Thread.java:834)&lt;/P&gt;&lt;P&gt;2023-04-09 20:46:43,880 ERROR [Timer-Driven Process Thread-1] o.a.n.p.standard.ExecuteStreamCommand ExecuteStreamCommand[id=65610950-0187-1000-7ef5-c5d0d5057e63] Transferring StandardFlowFileRecord[uuid=04a81cbc-9756-4346-b53a-b1d06555b0b7,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1681066003862-24, container=default, section=24], offset=0, length=7225],offset=0,name=edf174fc-eded-4480-bb09-5cf0adb9dc20,size=7225] to nonzero status. Executable command ncks ended in an error:&lt;/P&gt;&lt;P&gt;2023-04-09 20:46:44,363 INFO [Flow Service Tasks Thread-2] o.a.nifi.controller.StandardFlowService Saved flow controller org.apache.nifi.controller.FlowController@1344547c // Another save pending = false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now to me these errors are weird… It says the executable command ended in an error, thus I double-checked, downloaded the output flowfile from InvokeHTTP and ran ncks ‘filename’ in CMD. This works fine. I also ran the flow whereby I ignored STDIN and added the filename to the ‘Command Arguments’ (I had the file on disk), this works fine as well, though I must note the resulting flow file still has ‘Content Type:application/x-netcdf’ which I did not expect… (this is mostly just annoying since I cannot view the contents when the files are queued, however UpdateAttribute can fix this problem)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I wonder whether filesize/computation-time makes for too much trouble. Though it is not necessary a very heavy file, nor does the 'ncks' computation take long (185 KB, and subsecond respectively)… thus I do not think this is an issue. At this point I feel like there is nothing wrong with the command ‘ncks’. The error ‘De pipe is beëindigd’ translates to ‘the pipe has been ended’. I figured I look into the NiFi source code to understand where things(the pipe) break, it is here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java#L633" target="_blank" rel="noopener"&gt;https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java#L633&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I note that it is a bug previously discovered, however I really do not understand why it occurs. I know I could potentially work around the issue, I could write the file to disk and access it from there, however this really is not my preferred solution. I could also write something in Python, etc. to extract the data with ExecuteScript. Again, not preferred.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question boils down to two things, am I right the issue is with the bug, or am I doing something obvious/else wrong? If the problem is with the bug, how could I alter the source code such that it does work for my case? I do have some Java experience, however it is not my ‘best’ language as I mainly do analysis which is not in Java.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If needed I can supply additional info(pictures, etc.), I have tried quite a lot of things and spent a good amount of time on this problem. However thus far unsuccessful.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 09 Apr 2023 20:12:55 GMT</pubDate>
    <dc:creator>PieterNiFiHo</dc:creator>
    <dc:date>2023-04-09T20:12:55Z</dc:date>
    <item>
      <title>ExecuteStreamCommand behaves unexpected: pipe breaks</title>
      <link>https://community.cloudera.com/t5/Support-Questions/ExecuteStreamCommand-behaves-unexpected-pipe-breaks/m-p/368044#M240045</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, I work with spatial data which is in netCDF format. To manipulate and analyze the data I use the NCO toolkit, which consists of a bunch of commands. I run these in the Windows CMD. Though this works fine, it is somewhat slow and cumbersome. Thus I would like to automate this with NiFi. I figured the ExecuteStreamCommand would do the job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The netCDF data comes in via InvokeHTTP (generates a flowfile with ‘Content Type:application/x-netcdf’), and is subsequently fed to the ExecuteStreamCommand. I have it configured as follows &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PieterNiFiHo_0-1681068599810.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37224iCDDC0182D344F5BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PieterNiFiHo_0-1681068599810.png" alt="PieterNiFiHo_0-1681068599810.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;‘ncks’ is the executable command from the NCO Toolkit. This is on my path, such that I am sure NiFi can reach it. When I run the flow as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PieterNiFiHo_1-1681068647274.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/37225i02B366C82009B207/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PieterNiFiHo_1-1681068647274.png" alt="PieterNiFiHo_1-1681068647274.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I receive errors on the ExecuteStreamCommand processor. These are as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2023-04-09 20:46:43,879 ERROR [Thread-187] o.a.n.p.standard.ExecuteStreamCommand ExecuteStreamCommand[id=65610950-0187-1000-7ef5-c5d0d5057e63] Failed to write FlowFile to Standard Input Stream&lt;/P&gt;&lt;P&gt;java.io.IOException: De pipe is beëindigd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.io.FileOutputStream.writeBytes(Native Method)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.io.BufferedOutputStream.write(BufferedOutputStream.java:123)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.io.BufferedOutputStream.write(BufferedOutputStream.java:123)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.nifi.stream.io.StreamUtils.copy(StreamUtils.java:36)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.nifi.processors.standard.ExecuteStreamCommand.lambda$readStdoutReadable$1(ExecuteStreamCommand.java:633)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.base/java.lang.Thread.run(Thread.java:834)&lt;/P&gt;&lt;P&gt;2023-04-09 20:46:43,880 ERROR [Timer-Driven Process Thread-1] o.a.n.p.standard.ExecuteStreamCommand ExecuteStreamCommand[id=65610950-0187-1000-7ef5-c5d0d5057e63] Transferring StandardFlowFileRecord[uuid=04a81cbc-9756-4346-b53a-b1d06555b0b7,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1681066003862-24, container=default, section=24], offset=0, length=7225],offset=0,name=edf174fc-eded-4480-bb09-5cf0adb9dc20,size=7225] to nonzero status. Executable command ncks ended in an error:&lt;/P&gt;&lt;P&gt;2023-04-09 20:46:44,363 INFO [Flow Service Tasks Thread-2] o.a.nifi.controller.StandardFlowService Saved flow controller org.apache.nifi.controller.FlowController@1344547c // Another save pending = false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now to me these errors are weird… It says the executable command ended in an error, thus I double-checked, downloaded the output flowfile from InvokeHTTP and ran ncks ‘filename’ in CMD. This works fine. I also ran the flow whereby I ignored STDIN and added the filename to the ‘Command Arguments’ (I had the file on disk), this works fine as well, though I must note the resulting flow file still has ‘Content Type:application/x-netcdf’ which I did not expect… (this is mostly just annoying since I cannot view the contents when the files are queued, however UpdateAttribute can fix this problem)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I wonder whether filesize/computation-time makes for too much trouble. Though it is not necessary a very heavy file, nor does the 'ncks' computation take long (185 KB, and subsecond respectively)… thus I do not think this is an issue. At this point I feel like there is nothing wrong with the command ‘ncks’. The error ‘De pipe is beëindigd’ translates to ‘the pipe has been ended’. I figured I look into the NiFi source code to understand where things(the pipe) break, it is here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java#L633" target="_blank" rel="noopener"&gt;https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java#L633&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I note that it is a bug previously discovered, however I really do not understand why it occurs. I know I could potentially work around the issue, I could write the file to disk and access it from there, however this really is not my preferred solution. I could also write something in Python, etc. to extract the data with ExecuteScript. Again, not preferred.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question boils down to two things, am I right the issue is with the bug, or am I doing something obvious/else wrong? If the problem is with the bug, how could I alter the source code such that it does work for my case? I do have some Java experience, however it is not my ‘best’ language as I mainly do analysis which is not in Java.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If needed I can supply additional info(pictures, etc.), I have tried quite a lot of things and spent a good amount of time on this problem. However thus far unsuccessful.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 20:12:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/ExecuteStreamCommand-behaves-unexpected-pipe-breaks/m-p/368044#M240045</guid>
      <dc:creator>PieterNiFiHo</dc:creator>
      <dc:date>2023-04-09T20:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteStreamCommand behaves unexpected: pipe breaks</title>
      <link>https://community.cloudera.com/t5/Support-Questions/ExecuteStreamCommand-behaves-unexpected-pipe-breaks/m-p/368104#M240055</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/104500"&gt;@PieterNiFiHo&lt;/a&gt;,&amp;nbsp;Welcome to our community! To help you get the best possible answer, I have tagged our NiFi experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/95503"&gt;@steven-matison&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/42173"&gt;@ckumar&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/103151"&gt;@cotopaul&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;&amp;nbsp;who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 08:45:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/ExecuteStreamCommand-behaves-unexpected-pipe-breaks/m-p/368104#M240055</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2023-04-10T08:45:19Z</dc:date>
    </item>
  </channel>
</rss>

