Commons Exec
  1. Commons Exec
  2. EXEC-50

Pumping lines from the command output

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Labels:
      None

      Description

      My application makes heavy use of analyzing output lines of the long running executable. Executed command may run even up to to few hours. Actually I'm not so interested in the result of execution, but rather in the output produced by the program. Each line of the output contains some important data. I need to listen to these lines of the output, filter them and send JMS message containing selected of them.

      Current implementation of the StreamPumper makes it hard to listen to the output lines produced by the executable since it copies entire InputStream. What I did is pumping command output to the FilterInputStream and looking for the new line markers. It works for me, however it would be nice to have an ability to read entire lines from the PumpStream instead of raw bytes only. This is quite common case since executable usually format their output using the lines instead of the raw stream of bytes.

      I created patch refactoring StreamPumper to extend AbstractStreamPumper. I created also BufferedReaderPumper (also extending AbstractStreamPumper) to pump lines from the executable output and send them to the OutputLinesListener. I also extracted creation of the StreamPumper in the PumpStreamHandler to the factory method. This method can be overridden in order to use BufferedReaderPumper instead of default StreamPumper.

      What do you think about such approach?

      1. lines_listener.patch
        20 kB
        Henryk Konsek
      2. commons-exec.zip
        398 kB
        Henryk Konsek

        Activity

        Henryk Konsek created issue -
        Henryk Konsek made changes -
        Field Original Value New Value
        Attachment lines_listener.patch [ 12457781 ]
        Siegfried Goeschl made changes -
        Assignee Siegfried Goeschl [ sgoeschl ]
        Siegfried Goeschl made changes -
        Affects Version/s 1.2 [ 12315513 ]
        Siegfried Goeschl made changes -
        Fix Version/s 1.2 [ 12315513 ]
        Affects Version/s 1.1 [ 12313910 ]
        Affects Version/s 1.2 [ 12315513 ]
        Siegfried Goeschl made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Henryk Konsek made changes -
        Attachment commons-exec.zip [ 12458988 ]
        Gary Gregory made changes -
        Status In Progress [ 3 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Siegfried Goeschl
            Reporter:
            Henryk Konsek
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development