Mysql Ant:i/o重定向“;不得包含'<';“字符”;
我想在ant的build.xml文件中集成一个mysql语句 命令应为:Mysql Ant:i/o重定向“;不得包含'<';“字符”;,mysql,ant,Mysql,Ant,我想在ant的build.xml文件中集成一个mysql语句 命令应为: mysql -u$user -p$pwd -D$database < app/mysql/geo/data/geo.data.sql 我唯一能解决这个问题的方法是使用选项“-e”执行sql语句,然后使用SOURCE这有效: <exec executable="mysql"> <arg line="-u@{user} -p@{password} -D@{dat
mysql -u$user -p$pwd -D$database < app/mysql/geo/data/geo.data.sql
我唯一能解决这个问题的方法是使用选项“-e”执行sql语句,然后使用SOURCE这有效:
<exec executable="mysql">
<arg line="-u@{user} -p@{password} -D@{database} -e 'source app/mysql/geo/data/geo.data.sql'" />
</exec>
但是,我仍然对将ant的i/o重定向与mysql客户端结合使用的解决方案感兴趣。您需要转义<根据XML语法:
<exec executable="mysql">
<arg line="-u@{user} -p@{password} -D@{database} < app/mysql/geo/data/geo.data.sql" />
</exec>
I/O重定向不是这样工作的——它是shell所做的事情(至少在Unix上是这样)。在Ant中使用
或
的输入属性
Ant的网站上有几个专门针对这一点的常见问题,请参见感谢您提供这一有意义的提示,并使用escape the <exec executable="mysql">
<arg line="-u@{user} -p@{password} -D@{database} < app/mysql/geo/data/geo.data.sql" />
</exec>
populate-dev-geo-database:
[exec] mysql Ver 14.14 Distrib 5.5.43, for debian-linux-gnu (x86_64) using readline 6.2
[exec] Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
[exec]
[exec] Oracle is a registered trademark of Oracle Corporation and/or its
[exec] affiliates. Other names may be trademarks of their respective
[exec] owners.
[exec]
[exec] Usage: mysql [OPTIONS] [database]
[exec] -?, --help Display this help and exit.
[exec] -I, --help Synonym for -?
[exec] --auto-rehash Enable automatic rehashing. One doesn't need to use
[exec] Variables (--variable-name=value)
[exec] and boolean options {FALSE|TRUE} Value (after reading options)
[exec] --------------------------------- ----------------------------------------
[exec] auto-rehash TRUE
[exec] auto-vertical-output FALSE
<exec executable="mysql">
<arg line="-u@{user} -p@{password} -D@{database} -e 'source app/mysql/geo/data/geo.data.sql'" />
</exec>
<exec executable="mysql">
<arg line="-u@{user} -p@{password} -D@{database} < app/mysql/geo/data/geo.data.sql" />
</exec>