groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "KARR, DAVID" <dk0...@att.com>
Subject Questions about example of piping process output
Date Wed, 19 Aug 2015 19:56:47 GMT
While reading REGINA, I saw the following script:
--------------
def listFiles = 'ls'.execute()
def ignoreCase = "tr '[A-Z]' '[a-z]'".execute()
def reverseSort = 'sort -r'.execute()

listFiles | ignoreCase | reverseSort

reverseSort.waitForOrKill(1000)
if(reverseSort.exitValue()) {
    print reverseSort.err.text
} else {
    print reverseSort.text
}
-------------------

I find this curious.  It doesn't even seem to me that this could work as they intended, although
when I run it on Linux, it does apparently print reasonable output.  On Win7/Cygwin however,
it prints "-rThe system cannot find the file specified.".  Any idea what's going on here?

Also, the javadoc for "execute()" says that it starts the process and returns the process
object.  Ignoring for a moment why it completely fails on Cygwin, what exactly is the "pipe"
line actually doing?

Mime
View raw message