You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Jordan Grant <Jo...@carfax.com> on 2012/07/05 21:12:08 UTC

[exec] Portability of Different Approaches across Windows and OpenVMS

I have written two implementations using commons-exec that are functionally 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 portability.  I noticed that the CommandLauncherFactory is capable of producing a VmsCommandLauncher 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 basically the same?

1)
CommandLine cmd = CommandLine.parse("ping localhost");
DefaultExecutor executor = new DefaultExecutor();

2)
CommandLauncher launcher = CommandLauncherFactory.createVMLauncher();
CommandLine cmd = CommandLine.parse("ping localhost");
Process process = launcher.exec(cmd, null);
PumpStreamHandler outputHandler = new PumpStreamHandler();
outputHandler.setProcessOutputStream(process.getInputStream());
outputHandler.start();

process.waitFor();

outputHandler.stop();

Re: [exec] Portability of Different Approaches across Windows and OpenVMS

Posted by sebb <se...@gmail.com>.
On 6 July 2012 20:09, Jordan Grant <Jo...@carfax.com> wrote:
> Thank you for the tip, I will implement that soon. I guess the root of my question is, is there any downside to using the more concise DefaultExecutor approach?

If you want to be sure, check what the code does.

This is open source, so you have full access to the source.

> -----Original Message-----
> From: sebb [mailto:sebbaz@gmail.com]
> Sent: Friday, July 06, 2012 12:19 PM
> To: Commons Users List
> Subject: Re: [exec] Portability of Different Approaches across Windows and OpenVMS
>
> On 5 July 2012 20:12, Jordan Grant <Jo...@carfax.com> wrote:
>> I have written two implementations using commons-exec that are functionally 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 portability.  I noticed that the CommandLauncherFactory is capable of producing a VmsCommandLauncher 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 basically the same?
>>
>> 1)
>> CommandLine cmd = CommandLine.parse("ping localhost"); DefaultExecutor
>> executor = new DefaultExecutor();
>>
>> 2)
>> CommandLauncher launcher = CommandLauncherFactory.createVMLauncher();
>> CommandLine cmd = CommandLine.parse("ping localhost"); Process process
>> = launcher.exec(cmd, null); PumpStreamHandler outputHandler = 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
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: [exec] Portability of Different Approaches across Windows and OpenVMS

Posted by Jordan Grant <Jo...@carfax.com>.
Thank you for the tip, I will implement that soon. I guess the root of my question is, is there any downside to using the more concise DefaultExecutor approach?

-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com] 
Sent: Friday, July 06, 2012 12:19 PM
To: Commons Users List
Subject: Re: [exec] Portability of Different Approaches across Windows and OpenVMS

On 5 July 2012 20:12, Jordan Grant <Jo...@carfax.com> wrote:
> I have written two implementations using commons-exec that are functionally 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 portability.  I noticed that the CommandLauncherFactory is capable of producing a VmsCommandLauncher 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 basically the same?
>
> 1)
> CommandLine cmd = CommandLine.parse("ping localhost"); DefaultExecutor 
> executor = new DefaultExecutor();
>
> 2)
> CommandLauncher launcher = CommandLauncherFactory.createVMLauncher();
> CommandLine cmd = CommandLine.parse("ping localhost"); Process process 
> = launcher.exec(cmd, null); PumpStreamHandler outputHandler = 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




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [exec] Portability of Different Approaches across Windows and OpenVMS

Posted by sebb <se...@gmail.com>.
On 5 July 2012 20:12, Jordan Grant <Jo...@carfax.com> wrote:
> I have written two implementations using commons-exec that are functionally 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 portability.  I noticed that the CommandLauncherFactory is capable of producing a VmsCommandLauncher 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 basically the same?
>
> 1)
> CommandLine cmd = CommandLine.parse("ping localhost");
> DefaultExecutor executor = new DefaultExecutor();
>
> 2)
> CommandLauncher launcher = CommandLauncherFactory.createVMLauncher();
> CommandLine cmd = CommandLine.parse("ping localhost");
> Process process = launcher.exec(cmd, null);
> PumpStreamHandler outputHandler = 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