<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> <TITLE>Ant-contrib Tasks: ShellScript</TITLE> <META NAME="GENERATOR" CONTENT="OpenOffice.org 644 (Linux)"> <META NAME="CREATED" CONTENT="20030313;10303100"> <META NAME="CHANGED" CONTENT="20030318;15221000"> </HEAD> <BODY LANG="en-US" DIR="LTR"> <H1>ShellScript</H1> <P>Task definition for the <CODE>shellscript</CODE> task. This task allows the user to execute a script against a particular shell program on a machine. It is an extension of the "exec" task, and as such, supports the same attributes. One can however use "shell" instead of "executable". Also the "command" attribute is not allowed. See the ANT documentation for a description of the <exec> task parameters.</P> <H2>Parameters</H2> <TABLE WIDTH=854 BORDER=1 CELLPADDING=2 CELLSPACING=0> <COL WIDTH=84> <COL WIDTH=670> <COL WIDTH=86> <TR> <TH WIDTH=84> <P>Attribute</P> </TH> <TH WIDTH=670> <P>Description</P> </TH> <TH WIDTH=86> <P>Required</P> </TH> </TR> <TR> <TD WIDTH=84 VALIGN=TOP> <P>shell</P> </TD> <TD WIDTH=670 VALIGN=TOP> <P>The name of the shell executable which is to be executed. This shell must support taking a single parameter whose value is a script file which is to be executed. </P> </TD> <TD WIDTH=86> <P>Yes</P> </TD> </TR> <TR> <TD WIDTH=84 VALIGN=TOP> <P>executable</P> </TD> <TD WIDTH=670 VALIGN=TOP> <P>Same as “shell”</P> </TD> <TD WIDTH=86> <P><BR> </P> </TD> </TR> <TR VALIGN=TOP> <TD WIDTH=84> <P>tmpsuffix</P> </TD> <TD WIDTH=670> <P>The contents of the script are placed in a temporary file. This attribute is the extension to use. <B>note: </B>The value must contain any dots required. This attribute is usefull for using script files with windows </P> </TD> <TD WIDTH=86> <P>No</P> </TD> </TR> <TR VALIGN=TOP> <TD WIDTH=84> <P>inputstring</P> </TD> <TD WIDTH=670> <P>This is placed in the script file.</P> </TD> <TD WIDTH=86> <P>No</P> </TD> </TR> </TABLE> <H2>Nested Text</H2> <P>Any nested text is treated as the contents of the script that is to be executed within the shell. Embedded ant properties will be converted.</P> <H2>Examples</H2> <PRE> <shellscript shell="bash" dir="${src.mib.dir}"> mibgen -i ../include mib.mib -c ${build.gen.dir}/generated.cpp mibgen -i ../include mib.mib -h ${build.gen.dir}/generated.h </shellscript> <shellscript shell="sed" outputproperty="sed.output"> <arg value="-e"/> <arg value="s/FOO/BAR/g"/> FOO bar bar bar FOO bar bar </shellscript> <shellscript shell="cmd.exe" tmpsuffix=".bat"> <arg value="/c"/> <arg value="call"/> echo hello world </shellscript> <shellscript shell="bash" dir="${build.bin.dir}" inputstring="ls -rt | tail -n 1" outputproperty="last.bin.file"/> <shellscript executable="perl"> print STDOUT "Hello World!\n"; </shellscript> <shellscript shell="sh" dir="${thirdparty.dist.dir}/lib"> rm *.so for file in *.0 do x=`echo $file | sed -e's/.0.1.0//'` ln -s $file $x done </shellscript></PRE><P> <BR><BR> </P> <P><B>Warning:</B></P> <P STYLE="margin-left: 0.79in">One should be carefull in using <I>shellscript</I>, as overuse will make your build files difficult to understand, to maintain and to support multiplatform builds. Use of <I>cygwin</I> in a windows environment will help. However one should strive to use the java tasks whereever possible.</P> <PRE STYLE="margin-bottom: 0.2in"> </PRE> <HR> <P ALIGN=CENTER>Copyright © 2003 Ant-Contrib Project. All rights Reserved.</P> </BODY> </HTML>