The Windows batch file I am trying to run contains the following assignment:
set ANT_HOME="C:/Program Files/apache-ant-1.8.4"
The offending line is:
call %ANT_HOME%/bin/ant -f ../config/common.xml start_db
And when I run the script with echo on I get:
call "C:/Program_Files/apache-ant-1.8.4"/bin/ant -f ../config/common.xml start_db
Files/apache-ant-1.8.4""=="" was unexpected at this time.
I’ve moved the second quote to to the end of the path, after the ant, but I receive the same error message.
If ant were an .exe I would say your code should work. But I suspect that ant is a batch file, and the error is occurring within the ant script.
I base my conclusion on your error message – specifically the following portion of it:
""=="". The error message is a batch parsing error, and I don’t see how your code could generate those characters. So I figure ant must be a batch script that is causing the problem.I suspect ant.bat has
@echo offat the top, so you are not seeing the actual line that is failing.Not having access to the ant.bat script, I couldn’t possibly diagnose exactly what is failing, nor can I guess on how to fix it.
Update – exact problem found
I found a copy of ant.bat online.
It has the following line of code within:
Your definition of ANT_HOME includes enclosing quotes, so the code is trying to execute
The space is not quoted, and you have your error.
All you need to do to fix everything is to remove the quotes from the definition of ANT_HOME, and then add quotes to your CALL statement:
Forward-slashes are not always reliable as folder delimiters within Windows. See Why does the cmd.exe shell on Windows fail with paths using a forward-slash ('/'') path separator?.
Better to use back-slashes.