You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Morten Mortensen <mo...@tietoenator.com> on 2003/08/18 19:08:48 UTC

Task "exec" with attribute "output"

Hi all,

I experience some funny stuff with the "exec" task, when I set the "output"
attribute. It very much appears to me as if the output-stream does not get
flushed. Tried 1.5.3 and some 1.6's.

(I continue to have little luck with searching the bug-database; keep
getting lists a numbers out - probably a user-error - ...)

I suspect, that there is a "Runtime.exec()" hidden in there somewhere below
the "ExecTask". And some "Process.getOutputStream()". Instead I find lots of
OS-specific stuff (like direct invocation of "cmd.exe" instead of JNI with
::ShellExecuteEx() - well, fair enough!).

Where do I find the "Runtime.exec()" triggered by "ExecTask.execute()"?
I would like to have a closer look.

Have you ever discussed using a "SplitOutputStream" to have output from
"exec" guided to both a file and Ant-std-out at the same time - to see
progress while still preserving the information in a file - ? -Or a more
generic mechanism attached to Ant-std-out with tasks like "split-begin" and
"split-end"?

Hope one of you care to answer. :-)

Regards,
  Morten Sabroe Mortensen

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


Re: Task "exec" with attribute "output"

Posted by Steve Loughran <st...@iseran.com>.
Morten Mortensen wrote:
> Hi all,
> 
> I experience some funny stuff with the "exec" task, when I set the "output"
> attribute. It very much appears to me as if the output-stream does not get
> flushed. Tried 1.5.3 and some 1.6's.
> 
> (I continue to have little luck with searching the bug-database; keep
> getting lists a numbers out - probably a user-error - ...)
> 
> I suspect, that there is a "Runtime.exec()" hidden in there somewhere below
> the "ExecTask". 

yup

And some "Process.getOutputStream()".

Maybe in ExecuteStreamHandler

> Instead I find lots of
> OS-specific stuff (like direct invocation of "cmd.exe" instead of JNI with
> ::ShellExecuteEx() - well, fair enough!).

Well, we dont use non-standard JNI calls as that would need ant to build 
and run custom DLLS/shared libs. And I wouldnt use ::ShellExecuteEx() in 
that case anyway, because, well, its the wrong way to start command line 
programs in Win32.


> Where do I find the "Runtime.exec()" triggered by "ExecTask.execute()"?
> I would like to have a closer look.

Execute.java

There are custom inner classes to handle exec on different platforms 
*and* different Java runtimes. So that runtime.exec you seek is in 
there, maybe loaded via reflection.

> 
> Have you ever discussed using a "SplitOutputStream" to have output from
> "exec" guided to both a file and Ant-std-out at the same time - to see
> progress while still preserving the information in a file - ? -Or a more
> generic mechanism attached to Ant-std-out with tasks like "split-begin" and
> "split-end"?

You mean a more generic Unix style pipe architecture, dont you?

<exec something> | <grep > | <mail steve> ...

Its been thought about; Filterchains do it for transformations to files, 
but not for generic execution & output processing...you need to use 
intermediary files there

> 
> Hope one of you care to answer. :-)
> 
> Regards,
>   Morten Sabroe Mortensen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 



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


Re: Task "exec" with attribute "output"

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 18 Aug 2003, Morten Mortensen
<mo...@tietoenator.com> wrote:

> Have you ever discussed using a "SplitOutputStream" to have output
> from "exec" guided to both a file and Ant-std-out at the same time

We have a TeeOutputStream in Ant's util classes IIRC.

> - to see progress while still preserving the information in a file -

At least for stderr, this is possible in CVS HEAD via the logError
attribute.

Stefan

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