You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Rudolf Nottrott <rn...@alexandria.UCSB.edu> on 2004/01/26 18:05:25 UTC
run a class via a task with a particular working
directory
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
Re: run a class via a task with a particular working directory
Posted by "Clifton C. Craig" <cc...@icsaward.com>.
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