Page 1 of 1

URGENT! Problem with script from testing machine to production

Posted: 16 Jul 2018 10:54
by Scarlet
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
Am I missing anything? Is there any setting I should make that I am not aware of?

Thanks for any help!

Re: URGENT! Problem with script from testing machine to production

Posted: 16 Jul 2018 11:17
by ShadowThief
Without telling us what syntax error you get (and ideally providing a sample of code that also causes the same problem), we really have no way of knowing how to help you.

Re: URGENT! Problem with script from testing machine to production

Posted: 16 Jul 2018 11:27
by Scarlet
Error is: exit not expected at this time... I cannot provide script example right now since I'm commuting :(

Re: URGENT! Problem with script from testing machine to production

Posted: 16 Jul 2018 11:57
by Scarlet
This is part of the script and IT WORKS in TEST, but not in PRODUCTION:

Code: Select all

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!
)

Re: URGENT! Problem with script from testing machine to production

Posted: 16 Jul 2018 12:45
by aGerman
Several issues could cause your error.
First of all NEVER overwrite the already predefined path variable. Command line utilities will not be found anymore. Use another variable name.
Delayed expansion may cause failures if the passed parameters contain exclamation points.
Special characters like spaces, ampersands, or parentheses in the parameters may cause issues. Especially parentheses would fit to your error description.

It's all just guessing since nobody knows what parameters you passed though.

Steffen

Re: URGENT! Problem with script from testing machine to production

Posted: 16 Jul 2018 13:13
by Squashman
Another best practice is to use double quotes for your string comparisons. If the variable you are comparing has any special characters or spaces, the IF command will fail.

Try to get in the habit of doing this.

Code: Select all

if not "x%endname:file1_xxxx_=%"=="x%endname%" command

Re: URGENT! Problem with script from testing machine to production

Posted: 18 Jul 2018 11:49
by Scarlet
Thanks everyone, I solved the problem. Basically I rewrote the script.