From user-return-27562-apmail-commons-user-archive=commons.apache.org@commons.apache.org Fri Jul 6 17:19:13 2012 Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B973BDC34 for ; Fri, 6 Jul 2012 17:19:13 +0000 (UTC) Received: (qmail 17684 invoked by uid 500); 6 Jul 2012 17:19:12 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 17579 invoked by uid 500); 6 Jul 2012 17:19:12 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 17569 invoked by uid 99); 6 Jul 2012 17:19:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jul 2012 17:19:12 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sebbaz@gmail.com designates 209.85.214.171 as permitted sender) Received: from [209.85.214.171] (HELO mail-ob0-f171.google.com) (209.85.214.171) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jul 2012 17:19:06 +0000 Received: by obqv19 with SMTP id v19so3932247obq.30 for ; Fri, 06 Jul 2012 10:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=efwDteh/QHeueDg/lP606WXip6Lqri1J3iLeMqEbX9Y=; b=kdbT5KigC9sW6bhrhEXSYtEhw+eAZcHtsws39TPRBvYWPBHyimWUQPj2nL6AjZgAbt ZiW2ysRF9OtNZdHlvL7yak8PuT5Kx/ZkIm0EgRahT0EAor6sa8PL2PcZSe7Aqmjnkupe Z00SNJ3S9OvZ0em2Cf3bZwnze3PO65JAaC+lSIGeskLQlZMVLtayQa7t9GVuM5r2UfQI 1B+Z9b8D93qzVKPUXHraGKZznvovj94Cc1h7UP6rsp7aA9M0gr6hU5iki9wQNAeDJwPU EKQVrSW+67+K4ZHwvyz8SkAVBt8lZlp1WKbAotg8o05qvxe1fKlFLClXRapTSFSbtTCr 9erQ== MIME-Version: 1.0 Received: by 10.182.49.7 with SMTP id q7mr26605035obn.68.1341595125137; Fri, 06 Jul 2012 10:18:45 -0700 (PDT) Received: by 10.182.71.199 with HTTP; Fri, 6 Jul 2012 10:18:45 -0700 (PDT) In-Reply-To: References: Date: Fri, 6 Jul 2012 18:18:45 +0100 Message-ID: Subject: Re: [exec] Portability of Different Approaches across Windows and OpenVMS From: sebb To: Commons Users List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 5 July 2012 20:12, Jordan Grant wrote: > I have written two implementations using commons-exec that are functional= ly the same in Windows, but our production environment is in OpenVMS. I am= curious as to whether one approach or the other is preferred for portabili= ty. I noticed that the CommandLauncherFactory is capable of producing a Vm= sCommandLauncher and assume that the second approach is more portable than = the first somehow. Does the DefaultExecutor use the CommandLauncherFactory= and the CommandLauncher under the covers, rendering the approaches basical= ly the same? > > 1) > CommandLine cmd =3D CommandLine.parse("ping localhost"); > DefaultExecutor executor =3D new DefaultExecutor(); > > 2) > CommandLauncher launcher =3D CommandLauncherFactory.createVMLauncher(); > CommandLine cmd =3D CommandLine.parse("ping localhost"); > Process process =3D launcher.exec(cmd, null); > PumpStreamHandler outputHandler =3D new PumpStreamHandler(); > outputHandler.setProcessOutputStream(process.getInputStream()); > outputHandler.start(); > > process.waitFor(); > > outputHandler.stop(); This is not a full answer, but: Using CommandLine#parse() is not recommended for portability. Use CommandLine#addArgument() instead. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org