ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: Help with execon and mysql
Date Mon, 09 Jul 2001 04:50:23 GMT
On Mon,  9 Jul 2001 14:57, Rohit Peyyeti wrote:
> Hello:
>
> Has anyone tried using at with mysql? I have a directory in
> which all the .sql files are stored. I want Ant using <sql>
> or <execon> to run all of those .sql files in a directory.
>
> I tried using <execon>, but looks like it does not work.
> This is part of the build file:
>
>  <execon executable="mysql">
>    <arg value="-u"/>
>    <arg value="rtest"/>
>    <arg value="-h"/>
>    <arg value="helix"/>
>    <arg value="-P"/>
>    <arg value="3306"/>
>    <arg value="-prtest"/>
>    <arg value="-D"/>
>    <arg value="rtest"/>
>    <arg value="&lt;"/>
>     <srcfile/>
>      <fileset dir="/var/www/${virtualhost}/data" includes="*.sql"/>
>   </execon>
>
> When I run ant with debug option, this is what I get to see:
> [execon] Myos = Linux
> [execon] mysql -u rtest -h helix -P 3306 -prtest -D rtest <
> [execon] Executing mysql -u rtest -h helix -P 3306 -prtest -D rtest <
> /var/www/test/data/slogicdatadump.sql
>
> Technically speaking, this is right. When I run the above statement from
> the command line, this is what I get:
> ERROR 1045: Access denied for user: 'rtest@helix' (Using password: YES)
>
> Whereas, when I run through Ant, it shows me mysql help. Some thing like
> mysql --help.
>
> Any pointers?

When you execute it from the command line it is actually the shell that is 
interpreting the redirection (<) sign. When you execute it from ant there is 
no such interpretation. There are two ways to solve this. The first is that 
you create a shell script like

#!/bin/sh

mysql -u rtest -h helix -P 3306 -prtest -D rtest < $1

and then execute shell script with one parameter. The other way is to use 
execon on /bin/sh executable and supply -c option so your commanline looks 
like

/bin/sh -c mysql -u rtest -h helix -P 3306 -prtest -D rtest < ...

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*

Mime
View raw message