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!
URGENT! Problem with script from testing machine to production
Moderator: DosItHelp
URGENT! Problem with script from testing machine to production
Last edited by Scarlet on 16 Jul 2018 11:41, edited 1 time in total.
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: URGENT! Problem with script from testing machine to production
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
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
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!
Reason: Please use code formatting!
Re: URGENT! Problem with script from testing machine to production
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
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
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.
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
Thanks everyone, I solved the problem. Basically I rewrote the script.