You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David McTavish <dm...@SANDVINE.com> on 2003/02/07 18:53:38 UTC

Using Exec within my own Task, divert stdout to null?

Is there a way that I can divert the standard output of an exec task used
within my own custom task to /dev/null? (Without setting this as a
command-line argument?)


            ExecTask exec = createExec();
            if (runtimeDir != null)
            {
                Environment.Variable var = new Environment.Variable();
                var.setKey("PATH");
                var.setPath(runtimeDir);
                exec.addEnv(var);
            }
            exec.setFailonerror(true);
            exec.setDir(baseDir);
            exec.setExecutable("myexec.exe");
            exec.createArg().setValue("/i");
            exec.createArg().setValue(initString);
            exec.execute();

Also, any ideas on how to "correct" the environment variable above (PATH),
such that it works on both cygwin and Windows. It seems that when run on
Windows, it wants to use C:\folder\folder connotation, instead of
/c/folder/folder. Any insight would be appreciated.

thx,
d.

Re: Using Exec within my own Task, divert stdout to null?

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 7 Feb 2003, David McTavish <dm...@sandvine.com> wrote:

> Is there a way that I can divert the standard output of an exec task
> used within my own custom task to /dev/null?

exec.setTask(new File("/dev/null"));

> Also, any ideas on how to "correct" the environment variable above
> (PATH), such that it works on both cygwin and Windows.

No idea, sorry.

Stefan