MalTec
MalTec

Reputation: 1370

Unbalanced parenthesis and missing operator in batch file

The following code generates "Unbalanced parenthesis" on on the command prompt at the start and end of the for loop as well as "Missing Operator" at the end of the for loop. However, the code works fine. I found in other related question that it happens majorly due to nested brackets but even that is not present here.

for /R .\sql_queries %%m in (*.sql) do (
Echo Querying: %%~nm
::Querying with GAT  - Refer "for /?" for help on %%x variables 
java -Xms64m -Xmx512m -cp %mypath% com.app.GenericAxlTool -i %ip% -v 6.0 -a %axlVer% -d %DBVer% -u %userName% -p %password% -c sqlselect -f %%m >output.tmp
cd sql
ren *.tsv %%~nm.tsv >output.tmp
move %%~nm.tsv ..\Reports >output.tmp
cd..
)

Upvotes: 2

Views: 1866

Answers (3)

Zimba
Zimba

Reputation: 3683

CMD shell has been programmed to interpret the first close bracket ) to be associated with 1st open bracket ( in code blocks.

I got same errors when grouping codes in brackets. Found a discussion here: https://ss64.com/nt/syntax-brackets.html

Might help someone with workarounds.

Upvotes: 0

npocmaka
npocmaka

Reputation: 57272

The only way to produce "Unbalanced parenthesis." and "Missing operator." is with set /a command:

>set /a (
Missing operand.

>set /a (-1
Unbalanced parenthesis. 

but in the code you posted there's no SET /A invoke.

So or there's set /a as a string in some of your variables , or it fails in another part of your script.

Upvotes: 3

foxidrive
foxidrive

Reputation: 41244

UIAM Batch code doesn't have an "Unbalanced parenthesis" error message - it just fails silently.

It would seem than that the error is coming from the Java code.

Upvotes: 0

Related Questions