Return-Path: X-Original-To: apmail-groovy-users-archive@minotaur.apache.org Delivered-To: apmail-groovy-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DBAA318BF6 for ; Wed, 19 Aug 2015 20:42:29 +0000 (UTC) Received: (qmail 65189 invoked by uid 500); 19 Aug 2015 20:42:29 -0000 Delivered-To: apmail-groovy-users-archive@groovy.apache.org Received: (qmail 65158 invoked by uid 500); 19 Aug 2015 20:42:29 -0000 Mailing-List: contact users-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.incubator.apache.org Delivered-To: mailing list users@groovy.incubator.apache.org Received: (qmail 65148 invoked by uid 99); 19 Aug 2015 20:42:29 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Aug 2015 20:42:29 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id EF6B11AA825 for ; Wed, 19 Aug 2015 20:42:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.006 X-Spam-Level: X-Spam-Status: No, score=-0.006 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.006, SPF_HELO_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id vyzktVtgCtGp for ; Wed, 19 Aug 2015 20:42:21 +0000 (UTC) Received: from nelson.canoo.com (gate0.canoo.com [195.141.68.118]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 8FEF220F51 for ; Wed, 19 Aug 2015 20:42:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by nelson.canoo.com (Postfix) with ESMTP id 29BDC861D2D for ; Wed, 19 Aug 2015 22:42:19 +0200 (CEST) Received: from nelson.canoo.com ([127.0.0.1]) by localhost (nelson.canoo.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id WFnBagpF-dfN for ; Wed, 19 Aug 2015 22:42:17 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by nelson.canoo.com (Postfix) with ESMTP id C5A9E861DD2 for ; Wed, 19 Aug 2015 22:42:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at canoo.com Received: from nelson.canoo.com ([127.0.0.1]) by localhost (nelson.canoo.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BKckk5pB18G1 for ; Wed, 19 Aug 2015 22:42:17 +0200 (CEST) Received: from [10.0.1.19] (197.207.104.92.dynamic.wline.res.cust.swisscom.ch [92.104.207.197]) by nelson.canoo.com (Postfix) with ESMTPSA id 83934861D2D for ; Wed, 19 Aug 2015 22:42:17 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: Questions about example of piping process output From: =?utf-8?Q?Dierk_K=C3=B6nig?= In-Reply-To: Date: Wed, 19 Aug 2015 22:42:16 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: users@groovy.incubator.apache.org X-Mailer: Apple Mail (2.2102) Hi, thanks for reading the book! I was just about to answer when I recognized that I was about to restate = the text that follows the example: We=E2=80=99re using the pipeTo method of Process, which is invoked by = using the overridden or (|) operator. Then we wait for the process to finish with a safe time = to wait, and print the result. The observant reader (yes, that=E2=80=99s all of you!) will have = recognized that although the code is a slick solution, there=E2=80=99s also a pure Groovy = solution that=E2=80=99s platform independent =20 In other words, this solution _is_ platform dependent and cygwin is a = bit of a "unusual" platform to run commands at... keep groovin' Dierk > Am 19.08.2015 um 21:56 schrieb KARR, DAVID : >=20 > While reading REGINA, I saw the following script: > -------------- > def listFiles =3D 'ls'.execute() > def ignoreCase =3D "tr '[A-Z]' '[a-z]'".execute() > def reverseSort =3D 'sort -r'.execute() >=20 > listFiles | ignoreCase | reverseSort >=20 > reverseSort.waitForOrKill(1000) > if(reverseSort.exitValue()) { > print reverseSort.err.text > } else { > print reverseSort.text > } > ------------------- >=20 > 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? >=20 > 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?