You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Anderson, Kajsa" <Ka...@thomson.com> on 2004/01/27 17:19:10 UTC

RE: run a class via a task with a particular working d irectory

I know you can run a process as a different user on Windows, at least if
it's a scheduled process (though you do have to supply the password of the
user you're running as) - our nightly build script is set up like this.  Not
sure, though, if you can do it from the command line, which it sounds like
is what you would need.

Kajsa Anderson

-----Original Message-----
From: Clifton C. Craig [mailto:ccc@icsaward.com]
Sent: Tuesday, January 27, 2004 10:12 AM
To: Ant Users List
Subject: Re: run a class via a <java...> task with a particular working
directory


Hello Rudolf,

The working directory and user are specific to the Ant runtime unless
the fork attribute of the <java> task is set to true. In other words the
user and current directory used to start Ant will be the same used to
run your Java app. There is a dir attribute on the <java> task that you
can use to set this although I don't think there is a user setting as
this would most likely be platform specific. On Windows, for example I
don't think you can start a process as a different user while this may
be practical to Linux, Unix, and OS/400. As a work around you can use
the exec task with a shell script to modify your environment prior to
running your class. Note that you can only change these attributes in a
separate process and only set the user on specific platforms. This means
your java execution must be forked as the dir attribute is ignored when
fork = false. A better alternative would be to re-examine what your
ultimate goal is and ponder whether there are any better alternatives.

Cliff

Rudolf Nottrott wrote:

> Hello,
>
> When Ant runs a class via a <java...> task, it starts the class from a 
> particular with a particular working directory and as a particular 
> user.  How do I find out, at the time Ant executes the class, what the 
> directory/user are?   Is there some way of echoing these "hidden" 
> parameters?
>
> Also, over and above merely echoing these parameters (the class' 
> working directory / user), how can I set them.  In other words, I want 
> to tell Ant to run a particular class with <java...> task and give the 
> class a particular working director, say /somtask/taskdir, and run it 
> as a particular user, say 'tom'.
>
> Thanks for your advice.
>
> Rudolf
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>


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

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