You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by __matthewHawthorne <ma...@phreaker.net> on 2003/11/20 01:22:33 UTC
[lang] accessing environment variables
I posted something a while back about adding a method or class to access
environment vars. Henri suggested that I take a look at Ant's solution
to this.
Ant's env var access is obtained through their <execute> task. This
class has a lot of logic to handle different OS's, and I think that a
refactored version may be a worthwhile addition to lang.
I had my own small class to do this, but I would image that Ant's
version has been more thoroughly tested and bulletproofed.
Here's the link to Ant's Execute class.
http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java?rev=1.70&content-type=text/vnd.viewcvs-markup
Any thoughts? I think this would be very useful -- just about every
project that I've worked on has had to access env vars at some point or
another. And providing a nice simple way to execute system commands and
grab the output would be cool.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] accessing environment variables
Posted by __matthewHawthorne <ma...@phreaker.net>.
I didn't catch that. I also don't like the idea of batch files in
[lang], or any commons component really. I'm sure that we can find a
way to factor this out -- I'll keep looking.
Stephen Colebourne wrote:
> A quick glance shows a reference to a batch file needed for Windows95/98. My
> concern is that this may be a complex thing for [lang], although it probably
> is useful (I've never needed it)
> Stephen
>
>
> ----- Original Message -----
> From: "__matthewHawthorne" <ma...@phreaker.net>
>
>>I posted something a while back about adding a method or class to access
>>environment vars. Henri suggested that I take a look at Ant's solution
>>to this.
>>
>>Ant's env var access is obtained through their <execute> task. This
>>class has a lot of logic to handle different OS's, and I think that a
>>refactored version may be a worthwhile addition to lang.
>>
>>I had my own small class to do this, but I would image that Ant's
>>version has been more thoroughly tested and bulletproofed.
>>
>>Here's the link to Ant's Execute class.
>>
>
> http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/taskdefs
> /Execute.java?rev=1.70&content-type=text/vnd.viewcvs-markup
>
>>Any thoughts? I think this would be very useful -- just about every
>>project that I've worked on has had to access env vars at some point or
>>another. And providing a nice simple way to execute system commands and
>>grab the output would be cool.
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] accessing environment variables
Posted by Stephen Colebourne <sc...@btopenworld.com>.
A quick glance shows a reference to a batch file needed for Windows95/98. My
concern is that this may be a complex thing for [lang], although it probably
is useful (I've never needed it)
Stephen
----- Original Message -----
From: "__matthewHawthorne" <ma...@phreaker.net>
> I posted something a while back about adding a method or class to access
> environment vars. Henri suggested that I take a look at Ant's solution
> to this.
>
> Ant's env var access is obtained through their <execute> task. This
> class has a lot of logic to handle different OS's, and I think that a
> refactored version may be a worthwhile addition to lang.
>
> I had my own small class to do this, but I would image that Ant's
> version has been more thoroughly tested and bulletproofed.
>
> Here's the link to Ant's Execute class.
>
http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/taskdefs
/Execute.java?rev=1.70&content-type=text/vnd.viewcvs-markup
>
> Any thoughts? I think this would be very useful -- just about every
> project that I've worked on has had to access env vars at some point or
> another. And providing a nice simple way to execute system commands and
> grab the output would be cool.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] accessing environment variables
Posted by __matthewHawthorne <ma...@phreaker.net>.
I agree that it could grow to be a PITA. That's why I'm trying to be
wary, and limit the functionality that is offered.
The majority of Java apps that I've worked on were deployed on Unix
machines. In some situations, I was writing a replacement for an
existing piece of C or Perl code that relied heavy on environment variables.
I don't like env vars in Java apps -- I always try to rely on property
files or system properties. But it seems to be a battle that I always
lose. That's why I thought it would be nice to add this functionality
to [lang].
The problem is the abundance of platforms. Just in looking at the Ant
code, they have if/elses for things like Vms and OS2 that I've never
used. What a headache.
I'm starting to think that maybe this isn't good for [lang] either. If
anywhere, maybe it should go into [io] instead.
Has anyone else found themselves having to load environment variables in
their apps? If not, I'm willing to continue cut and pasting my
solution into each of my projects, instead of creating an unnecessary
platform issue for [lang].
Phil Steitz wrote:
> __matthewHawthorne wrote:
>
>> I posted something a while back about adding a method or class to access
>> environment vars. Henri suggested that I take a look at Ant's solution
>> to this.
>>
>> Ant's env var access is obtained through their <execute> task. This
>> class has a lot of logic to handle different OS's, and I think that a
>> refactored version may be a worthwhile addition to lang.
>>
>> I had my own small class to do this, but I would image that Ant's
>> version has been more thoroughly tested and bulletproofed.
>>
>> Here's the link to Ant's Execute class.
>> http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java?rev=1.70&content-type=text/vnd.viewcvs-markup
>>
>>
>> Any thoughts? I think this would be very useful -- just about every
>> project that I've worked on has had to access env vars at some point or
>> another. And providing a nice simple way to execute system commands and
>> grab the output would be cool.
>>
>
>
> While I can definitely see the value for this kind of capability in a
> build script, I am not sure it belongs in [lang]. I am not violently
> opposed, just not convinced that it belongs. Could be I am thinking too
> narrowly in terms of server apps, where I generally try to avoid system
> calls and environment dependencies like the plague, since these things
> can lead to brittle solutions and general deployment trauma. Seems like
> a big PITA to support this kind of thing in a platform-independent (at
> least from the user's standpoint) way that is safe to use in server
> applications.
>
> Phil
>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] accessing environment variables
Posted by Phil Steitz <ph...@steitz.com>.
__matthewHawthorne wrote:
> I posted something a while back about adding a method or class to access
> environment vars. Henri suggested that I take a look at Ant's solution
> to this.
>
> Ant's env var access is obtained through their <execute> task. This
> class has a lot of logic to handle different OS's, and I think that a
> refactored version may be a worthwhile addition to lang.
>
> I had my own small class to do this, but I would image that Ant's
> version has been more thoroughly tested and bulletproofed.
>
> Here's the link to Ant's Execute class.
> http://cvs.apache.org/viewcvs.cgi/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java?rev=1.70&content-type=text/vnd.viewcvs-markup
>
>
> Any thoughts? I think this would be very useful -- just about every
> project that I've worked on has had to access env vars at some point or
> another. And providing a nice simple way to execute system commands and
> grab the output would be cool.
>
While I can definitely see the value for this kind of capability in a
build script, I am not sure it belongs in [lang]. I am not violently
opposed, just not convinced that it belongs. Could be I am thinking too
narrowly in terms of server apps, where I generally try to avoid system
calls and environment dependencies like the plague, since these things
can lead to brittle solutions and general deployment trauma. Seems like
a big PITA to support this kind of thing in a platform-independent (at
least from the user's standpoint) way that is safe to use in server
applications.
Phil
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org