Why does a script that runs in test not run in production?

July 16, 2018 at 10:04:29
Specs: Macintosh
Hi everyone,

I have a problem with a script running on Windows 2008. The script is 2000 rows each made of 120 characters with basic commands. Whenever I run the script on test machine, everything works smoothly, but when I try and make it run on the production machine (same Windows version and setup), I get a syntax error.

Error is: exit not expected at this time

This is part of the script and IT WORKS in TEST, but not in PRODUCTION:

setlocal EnableExtensions EnableDelayedExpansion
set path=%1
set endname=%2
set acreate=%3
set docserver=%4
set vdruser=%5
set vdrpasswd=%6
set tickedId=%7
if not x%endname:file1_xxxx_=%==x%endname% (
%acreate% -S %docserver% -u %vdruser% -p %vdrpasswd% -f %path%\%fname% -r file1_DER -m P -c file1_DER
exit /b !ERRORLEVEL!
) else if not x%endname:file2_Yyyy_=%==x%endname% (
%acreate% -S %docserver% -u %vdruser% -p %vdrpasswd% -f %path%\%fname% -r file2_DER -m P -c file2_DER
exit /b !ERRORLEVEL!
)

Am I missing anything? Is there any setting I should make that I am not aware of?

Thanks for any help!

message edited by scarlet70


See More: Why does a script that runs in test not run in production?

Reply ↓  Report •

#1
July 17, 2018 at 05:07:58
This is a GUESS, so don't ask for a refund.

CMD extensions are enabled on one box & disabled on the other.

2018-07-17 19:06:52.33 GMT +7

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

#2
July 17, 2018 at 07:16:10
What line gives you a syntax error? What does that line look like in production, once all of the variables are substituted?

How To Ask Questions The Smart Way


Reply ↓  Report •

#3
July 17, 2018 at 07:39:35
Nevermind my comment about extensions.

I don't know what your 7 parameters are.
Are they identical on both boxes?

How is %endname:file1_xxxx_=% getting set?

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

Related Solutions

#4
July 17, 2018 at 19:06:01
To me, it looks like a line-break difference (CR/LF) interpretation between systems. If "exit" is interpreted as being on the same line as the preceding code on the production environment, then that might generate such an error. At any rate, I would just take out the entire EXIT line in both parts and let nature take its course (unless there's some pressing reason to return the errorlevel, which might be returned correctly regardless).
Also, the logic and construction of this code is bad: unclear, easy to misinterpret, and redundant, but I will go no further down that road...

message edited by nbrane


Reply ↓  Report •

#5
July 18, 2018 at 10:54:54
Rewrote te script and reduced it from 2000 lines to only a few. Seems to work now.

Reply ↓  Report •

Ask Question