ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brian.ew...@btinternet.com
Subject Re: Using Ant to <exec> a shell script
Date Mon, 19 Nov 2001 18:26:33 GMT
The executable should be 'expect' not 'sh', as below. The command line equivalent of what you
did is not:
./reactor_smoketest
but
/bin/sh ./reactor_smoketest
which is very much not what you want :). Try this commandline to check for yourself that it
does the same as ant says.

Fixed target:
   <target name="smoke.test.starnode"
           depends="init"
           description="- This target executes the Starnode smoke test
 shell script.">
      <exec dir="/export/home/stargus/tests"
            vmlauncher="false"            executable="/usr/local/bin/expect">
        <arg line="./reactor_smoketest ${test.case} ${build.number}"/>
     </exec>
   </target>

An alternate, better way of writing this (since you clearly have the executable bit set on
your script) is to do this:
   <target name="smoke.test.starnode"
           depends="init"
           description="- This target executes the Starnode smoke test
 shell script.">
      <exec dir="/export/home/stargus/tests"
            vmlauncher="false"            executable="./reactor_smoketest">
        <arg value="${test.case}"/>
        <arg value="${build.number}"/>
     </exec>
   </target>

Using separate args should also mean that ant takes care of command line quoting for you.

HTH 
Baz
> Hi,
> 
> I have an <exec> task that calls a shell script on Unix to kick off a
> smoke test. The shell script is actually calling the Expect executable
> as follows:
> 
> #!/usr/local/bin/expect --
> 
> The relevant snippet from my build.xml is as follows:
> 
>   <target name="smoke.test.starnode"
>           depends="init"
>           description="- This target executes the Starnode smoke test
> shell script.">
>      <exec dir="/export/home/stargus/tests"
>            vmlauncher="false"
>            executable="/usr/bin/sh">
>        <arg line="./reactor_smoketest ${test.case} ${build.number}"/>
>     </exec>
>   </target>
> 
> For some reason, it would appear that when Ant invokes the shell script,
> the shell script itself is not invoking Expect. However, when I execute
> the shell script directly, (e.g. ./reactor_smoketest, it runs just fine.
> The -debug output from Ant is as follows:
> 
> smoke.test.starnode:
>      [exec] Current OS is SunOS
>      [exec] /usr/bin/sh ./reactor_smoketest pre test
> Execute:CommandLauncher: /usr/local/ant/bin/antRun
> /export/home/stargus/tests /usr/bin/sh ./reactor_smoketest pre test
>      [exec] ./reactor_smoketest: proc: not found
>      [exec] ./reactor_smoketest: send_log: not found
>      [exec] ./reactor_smoketest: puts: not found
>      [exec] ./reactor_smoketest: syntax error at line 7: `}' unexpected
>      [exec] Result: 2
> 
> We are looking at having the buildfile <exec> Expect directly and then
> passing the script to the Expect as an argument. However, it seems like
> our first approach should work. Has anyone run into anything similar and
> come up with a valid workaround? Do I need to pass additional args?
> 
> Cheers,
> 
> Matt
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message