| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <HTML> |
| 3 | <HEAD> |
| 4 | <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> |
| 5 | <TITLE>Ant-contrib Tasks: ShellScript</TITLE> |
| 6 | <META NAME="GENERATOR" CONTENT="OpenOffice.org 644 (Linux)"> |
| 7 | <META NAME="CREATED" CONTENT="20030313;10303100"> |
| 8 | <META NAME="CHANGED" CONTENT="20030318;15221000"> |
| 9 | </HEAD> |
| 10 | <BODY LANG="en-US" DIR="LTR"> |
| 11 | <H1>ShellScript</H1> |
| 12 | <P>Task definition for the <CODE>shellscript</CODE> task. This task |
| 13 | allows the user to execute a script against a particular shell |
| 14 | program on a machine. It is an extension of the "exec" |
| 15 | task, and as such, supports the same attributes. One can however use |
| 16 | "shell" instead of "executable". Also the |
| 17 | "command" attribute is not allowed. See the ANT |
| 18 | documentation for a description of the <exec> task parameters.</P> |
| 19 | <H2>Parameters</H2> |
| 20 | <TABLE WIDTH=854 BORDER=1 CELLPADDING=2 CELLSPACING=0> |
| 21 | <COL WIDTH=84> |
| 22 | <COL WIDTH=670> |
| 23 | <COL WIDTH=86> |
| 24 | <TR> |
| 25 | <TH WIDTH=84> |
| 26 | <P>Attribute</P> |
| 27 | </TH> |
| 28 | <TH WIDTH=670> |
| 29 | <P>Description</P> |
| 30 | </TH> |
| 31 | <TH WIDTH=86> |
| 32 | <P>Required</P> |
| 33 | </TH> |
| 34 | </TR> |
| 35 | <TR> |
| 36 | <TD WIDTH=84 VALIGN=TOP> |
| 37 | <P>shell</P> |
| 38 | </TD> |
| 39 | <TD WIDTH=670 VALIGN=TOP> |
| 40 | <P>The name of the shell executable which is to be executed. This |
| 41 | shell must support taking a single parameter whose value is a |
| 42 | script file which is to be executed. |
| 43 | </P> |
| 44 | </TD> |
| 45 | <TD WIDTH=86> |
| 46 | <P>Yes</P> |
| 47 | </TD> |
| 48 | </TR> |
| 49 | <TR> |
| 50 | <TD WIDTH=84 VALIGN=TOP> |
| 51 | <P>executable</P> |
| 52 | </TD> |
| 53 | <TD WIDTH=670 VALIGN=TOP> |
| 54 | <P>Same as “shell”</P> |
| 55 | </TD> |
| 56 | <TD WIDTH=86> |
| 57 | <P><BR> |
| 58 | </P> |
| 59 | </TD> |
| 60 | </TR> |
| 61 | <TR VALIGN=TOP> |
| 62 | <TD WIDTH=84> |
| 63 | <P>tmpsuffix</P> |
| 64 | </TD> |
| 65 | <TD WIDTH=670> |
| 66 | <P>The contents of the script are placed in a temporary file. This |
| 67 | attribute is the extension to use. <B>note: </B>The value must |
| 68 | contain any dots required. This attribute is usefull for using |
| 69 | script files with windows |
| 70 | </P> |
| 71 | </TD> |
| 72 | <TD WIDTH=86> |
| 73 | <P>No</P> |
| 74 | </TD> |
| 75 | </TR> |
| 76 | <TR VALIGN=TOP> |
| 77 | <TD WIDTH=84> |
| 78 | <P>inputstring</P> |
| 79 | </TD> |
| 80 | <TD WIDTH=670> |
| 81 | <P>This is placed in the script file.</P> |
| 82 | </TD> |
| 83 | <TD WIDTH=86> |
| 84 | <P>No</P> |
| 85 | </TD> |
| 86 | </TR> |
| 87 | </TABLE> |
| 88 | <H2>Nested Text</H2> |
| 89 | <P>Any nested text is treated as the contents of the script that is |
| 90 | to be executed within the shell. Embedded ant properties will be |
| 91 | converted.</P> |
| 92 | <H2>Examples</H2> |
| 93 | <PRE> <shellscript shell="bash" dir="${src.mib.dir}"> |
| 94 | mibgen -i ../include mib.mib -c ${build.gen.dir}/generated.cpp |
| 95 | mibgen -i ../include mib.mib -h ${build.gen.dir}/generated.h |
| 96 | </shellscript> |
| 97 | |
| 98 | <shellscript shell="sed" outputproperty="sed.output"> |
| 99 | <arg value="-e"/> |
| 100 | <arg value="s/FOO/BAR/g"/> |
| 101 | FOO bar bar bar FOO bar bar |
| 102 | </shellscript> |
| 103 | |
| 104 | <shellscript shell="cmd.exe" tmpsuffix=".bat"> |
| 105 | <arg value="/c"/> |
| 106 | <arg value="call"/> |
| 107 | echo hello world |
| 108 | </shellscript> |
| 109 | |
| 110 | <shellscript shell="bash" |
| 111 | dir="${build.bin.dir}" |
| 112 | inputstring="ls -rt | tail -n 1" |
| 113 | outputproperty="last.bin.file"/> |
| 114 | |
| 115 | <shellscript executable="perl"> |
| 116 | print STDOUT "Hello World!\n"; |
| 117 | </shellscript> |
| 118 | |
| 119 | <shellscript shell="sh" dir="${thirdparty.dist.dir}/lib"> |
| 120 | rm *.so |
| 121 | for file in *.0 |
| 122 | do |
| 123 | x=`echo $file | sed -e's/.0.1.0//'` |
| 124 | ln -s $file $x |
| 125 | done |
| 126 | </shellscript></PRE><P> |
| 127 | <BR><BR> |
| 128 | </P> |
| 129 | <P><B>Warning:</B></P> |
| 130 | <P STYLE="margin-left: 0.79in">One should be carefull in using |
| 131 | <I>shellscript</I>, as overuse will make your build files difficult |
| 132 | to understand, to maintain and to support multiplatform builds. Use |
| 133 | of <I>cygwin</I> in a windows environment will help. However one |
| 134 | should strive to use the java tasks whereever possible.</P> |
| 135 | <PRE STYLE="margin-bottom: 0.2in"> </PRE> |
| 136 | <HR> |
| 137 | <P ALIGN=CENTER>Copyright © 2003 Ant-Contrib Project. All rights |
| 138 | Reserved.</P> |
| 139 | </BODY> |
| 140 | </HTML> |