madams
2nd July 2007 16:25 UTC
SQL File Execution Problems
Hi,
I am simply trying to execute an SQL file to create a database in mySql. Whenever I try using either of the code snippets below however, I always get errors.
When I try using this:
nsExec::ExecToLog 'cmd /C "$mySQLEXE" -uroot -p$databaseLoginPass < "$databaseConfigFile"'
(Where $mySQLEXE is the path to the mysql.exe file, $databasepass is the root user password, and $databaseConfigFile is the full path to the SQL file.)
I get the error: 'C:\Program' is not recognized as an internal or external command,operable program or batch file. I have doubled checked all the paths and the database password, and everything is correct.
When I try using this:
nsExec::ExecToLog '"cmd /C "$mySQLEXE" -uroot -p$databaseLoginPass < "$databaseConfigFile""'
I don't get an error, but no database is created.
If anybody knows what is going on please let me know.
Thanks!
kichik
2nd July 2007 19:09 UTC
That's just cmd.exe messing with your quotes.
1. If all of the following conditions are met, then quote character
on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more whitespace characters between the
the two quote characters
- the string between the two quote characters is the name
of an executable file.
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.
Add
IF 1==1 right after
/C or use a short filename for $mysqlexe (GetFullPathName /SHORT).
madams
2nd July 2007 19:31 UTC
Thanks a lot kichik, the IF 1==1 thing worked perfectly.