URGENT! Problem with script from testing machine to production

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Scarlet
Posts: 4
Joined: 16 Jul 2018 10:26

URGENT! Problem with script from testing machine to production

#1 Post by Scarlet » 16 Jul 2018 10:54

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!
Last edited by Scarlet on 16 Jul 2018 11:41, edited 1 time in total.

ShadowThief
Expert
Posts: 901
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

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

#2 Post by ShadowThief » 16 Jul 2018 11:17

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.

Scarlet
Posts: 4
Joined: 16 Jul 2018 10:26

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

#3 Post by Scarlet » 16 Jul 2018 11:27

Error is: exit not expected at this time... I cannot provide script example right now since I'm commuting :(

Scarlet
Posts: 4
Joined: 16 Jul 2018 10:26

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

#4 Post by Scarlet » 16 Jul 2018 11:57

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!
)
Last edited by aGerman on 16 Jul 2018 12:33, edited 1 time in total.
Reason: Please use code formatting!

aGerman
Expert
Posts: 3669
Joined: 22 Jan 2010 18:01
Location: Germany

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

#5 Post by aGerman » 16 Jul 2018 12:45

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

Squashman
Expert
Posts: 4107
Joined: 23 Dec 2011 13:59

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

#6 Post by Squashman » 16 Jul 2018 13:13

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

Scarlet
Posts: 4
Joined: 16 Jul 2018 10:26

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

#7 Post by Scarlet » 18 Jul 2018 11:49

Thanks everyone, I solved the problem. Basically I rewrote the script.

Post Reply