You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by stephan beal <st...@wanderinghorse.net> on 2002/04/24 13:20:05 UTC

new task: ShellScriptTask

Yo,

i know this isn't exactly canon, but attached is an ExecTask subclass which 
may be useful for any Unix froods out there. It allows you to write inline 
scripts for arbitrary scripting tools:

<taskdef name="shellscript" 
classname="net.sf.antcontrib.logic.ShellScriptTask"/>


<shellscript>
	echo This is my inline shell script
 	echo PWD=$PWD
	echo user=$USER
</shellscript>
(defaults to using shell /bin/bash)

<shellscript executable="/bin/sed">
	<arg value="-n"/>
	<arg line="-e 's/FOO/BAR/gp'"/>
one two
FOO bar bar bar bar FOO FOO bar
three four
</shellscript>

<shellscript executable="/usr/bin/make">
	<arg value="-f"/>
default: all
foo = this is a makefile
all:
	@echo foo=$(foo)
</shellscript>

<shellscript executable="/usr/bin/perl"><![CDATA[
	print "Hello, World!\n";
	open IN, "</etc/hosts" or die "Error opening build file!\n";
	@foo=<IN>;
#	print join( "",@foo ),"\n";
]]></shellscript>


     [bash] This is my inline shell script
     [bash] PWD=/home/stephan/cvs/einsurance
     [bash] user=stephan
      [sed] BAR bar bar bar bar BAR BAR bar
     [make] make[1]: Entering directory `/home/stephan/cvs/einsurance'
     [make] foo=this is a makefile
     [make] make[1]: Leaving directory `/home/stephan/cvs/einsurance'
     [perl] Hello, World!


Tested against ant 1.4.1.
It's a subclass of ExecTask, so it supports all of the <exec> options as well.


----- stephan
stephan@einsurance.de - http://www.einsurance.de
Office: +49 (89)  552 92 862 Handy:  +49 (179) 211 97 67
"I didn't give in to the Nazis and I won't give in to the bladder." 
- The Queen Mum

Re: new task: ShellScriptTask

Posted by John Keyes <jb...@mac.com>.
> > I have a patch for 'ForEach' that I emailed to the two maintainers
> > of 'ant-contrib' but received no response.
> 
> I've applied your patch (well, something similar) on Monday - sorry, I
> thought you'd be subscribed to the mailing list or I would have sent
> you a notice as well.
I'm subscribed now 8^)

> > but are the mailing lists at ant-contrib monitored regularly?
> 
> Yes - more regularly than the patch tracker it seems.
Cool.  Thanks,
-John K



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: new task: ShellScriptTask

Posted by Stefan Bodewig <bo...@apache.org>.
On 24 Apr 2002, John Keyes <jb...@mac.com> wrote:

> I have a patch for 'ForEach' that I emailed to the two maintainers
> of 'ant-contrib' but received no response.

I've applied your patch (well, something similar) on Monday - sorry, I
thought you'd be subscribed to the mailing list or I would have sent
you a notice as well.

> This isn't the correct forum for this

True. 8-)

> but are the mailing lists at ant-contrib monitored regularly?

Yes - more regularly than the patch tracker it seems.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: new task: ShellScriptTask

Posted by John Keyes <jb...@mac.com>.
Stefan,

What is the best approach for patches to tasks in
ant-contrib.  I have a patch for 'ForEach' that I
emailed to the two maintainers of 'ant-contrib' but
received no response.  This isn't the correct forum
for this but are the mailing lists at ant-contrib
monitored regularly?

-John K

On Wed, 2002-04-24 at 13:12, Stefan Bodewig wrote:
> On Wed, 24 Apr 2002, stephan beal <st...@wanderinghorse.net> wrote:
> 
> > i sent it to their Patches page earlier,
> 
> I must admit that I (even though I'm a committer to ant-contrib) have
> never looked at the patch tracker - thanks for the pointer.
> 
> > If it's not appropriate to post tasks here, please let me know and
> > i'll stop doing so.
> 
> I'm not sure, I'd probably prefer a pointer to and a description of
> the task instead of the complete source code.  But it could be just
> me.
> 
> Stefan
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: new task: ShellScriptTask

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 24 Apr 2002, stephan beal <st...@wanderinghorse.net> wrote:

> i sent it to their Patches page earlier,

I must admit that I (even though I'm a committer to ant-contrib) have
never looked at the patch tracker - thanks for the pointer.

> If it's not appropriate to post tasks here, please let me know and
> i'll stop doing so.

I'm not sure, I'd probably prefer a pointer to and a description of
the task instead of the complete source code.  But it could be just
me.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: new task: ShellScriptTask

Posted by stephan beal <st...@wanderinghorse.net>.
On Wednesday 24 April 2002 13:37, Stefan Bodewig wrote:
> On Wed, 24 Apr 2002, stephan beal <st...@wanderinghorse.net> wrote:
> > classname="net.sf.antcontrib.logic.ShellScriptTask"/>
>
> Are you sure that you didn't mean to send it to
> ant-contrib-developers@lists.sourceforge.net 8-)

i sent it to their Patches page earlier, but thought it might be useful for 
someone on this list. If it's not appropriate to post tasks here, please let 
me know and i'll stop doing so.

----- stephan
stephan@einsurance.de - http://www.einsurance.de
Office: +49 (89)  552 92 862 Handy:  +49 (179) 211 97 67
"I didn't give in to the Nazis and I won't give in to the bladder." 
- The Queen Mum


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: new task: ShellScriptTask

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 24 Apr 2002, stephan beal <st...@wanderinghorse.net> wrote:

> classname="net.sf.antcontrib.logic.ShellScriptTask"/>

Are you sure that you didn't mean to send it to
ant-contrib-developers@lists.sourceforge.net 8-)

Stefan


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>