I am trying to list the content fo an svn folder which contains about 1200 items. Along the lines in "Execute a external program within a groovy script and capture the output", I developed the following code
def svnCommand = "svn list ${repoUrl}"
def sout = new StringBuilder()
def serr = new StringBuilder()
Process sproc = svnCommand.execute()
sproc.consumeProcessOutput(sout, serr)
sproc.waitForProcessOutput()
println sout
If I am going to run this script I always get a truncated output, no matter how high I may set initial capacity. The output is evidently truncated, as shown in the following excerpt
...
SS0D76I0.cpy
SS0D76M0.cpy
SS0D76N0.cpy
SS
Any suggestion about capturing the full output of the command? The script is running on a Windows box.
public void consumeProcessOutput(Appendable output, Appendable error)
:
Gets the output and error streams from a process and reads them to keep the process from blocking due to a full output buffer. The processed stream data is appended to the supplied Appendable. For this, two Threads are started, so this method will return immediately. The threads will not be join()ed, even if waitFor() is called. To wait for the output to be fully consumed call waitForProcessOutput().
public void waitForProcessOutput()
Gets the output and error streams from a process and reads them to keep the process from blocking due to a full output buffer. The stream data is thrown away but blocking due to a full output buffer is avoided. Use this method if you don't care about the standard or error output and just want the process to run silently - use carefully however, because since the stream data is thrown away, it might be difficult to track down when something goes wrong. For this, two Threads are started, but join()ed, so we wait. As implied by the waitFor... name, we also wait until we finish as well. Finally, the output and error streams are closed.
public void waitForProcessOutput(Appendable output, Appendable error)
Gets the output and error streams from a process and reads them to keep the process from blocking due to a full output buffer. The processed stream data is appended to the supplied Appendable. For this, two Threads are started, but join()ed, so we wait. As implied by the waitFor... name, we also wait until we finish as well. Finally, the input, output and error streams are closed.
so, instead of
sproc.consumeProcessOutput(sout, serr)
sproc.waitForProcessOutput()
call
sproc.waitForProcessOutput(sout, serr)