tags:

views:

184

answers:

2

I'm trying to setup an mysql import script in Phing, but the "<" is causing XML errors. Any ideas?

<exec command="mysql -u${mysql.username} -p${mysql.password} -h ${mysql.server} ${mysql.database} < ${sql.file}" />

I'm looking at making dbDeploy doing this, but it'd be great if there was an easy way for this to work (single line command versus the multi-line setup of dbDeploy)

+2  A: 

Escape the character by replacing it with &lt;

nickf
so simple. duh. thanks.
jmccartie
A: 

I'm not familiar with Phing, but it may not be executing the command in a shell, so the redirect operator won't work (it may be treating the operator as an argument to mysql itself).

Instead of < ${sql.file}, try -e 'source ${sql.file}', so your whole line is:

<exec command="mysql -u${mysql.username} -p${mysql.password} -h ${mysql.server} ${mysql.database} -e 'source ${sql.file}'" />

See the MySQL batch mode documentation.

Phil M