Solved

dos batch if error

Posted on 2011-09-15
11
369 Views
Last Modified: 2012-05-12
i keep on getting an error with this if statment in my batch file. it states
"Else was unexpected at this time."

I know it does go into the else branch becasue i see the echo.s in the log file

I use the

   set OpertionName=CopyFiles
   call:ExecuteCommand

in an earlier part of the batch program and at that point the command works well.

i have copied out the function below. please help if you can
Thanks in advance

::-----------------------------------------------------------
:: Define DeployToRunTime
::-----------------------------------------------------------
:DeployToRunTime
if /i "%ApplicationOwner%" equ "IFS"  (
   echo this is for IFS >> %dosDumpFileName%
   echo set CitrixRunTimeLoc=%Citrix%%CitrixIFS% >> %dosDumpFileName%
   set DestinationFileDir=%Citrix%%CitrixIFS%
) else (
   echo this is not for IFS >> %dosDumpFileName%
   echo this is for %ApplicationOwner% >> %dosDumpFileName%
   echo set CitrixRunTimeLoc=%Citrix%%CitrixIFS%%MACRunTimeLoc% >> %dosDumpFileName%
   set DestinationFileDir=%Citrix%%CitrixIFS%%MACRunTimeLoc%
   set OLDPrefix=OLD_RUNTIME_
   set OpertionName=CopyFiles
   call:ExecuteCommand
)
GOTO:EOF
0
Comment
Question by:jhacharya
  • 7
  • 3
11 Comments
 
LVL 2

Author Comment

by:jhacharya
ID: 36543228
here is the the copy files

::------------------------------------------------------------
:: Define how to copy the files
::------------------------------------------------------------
:CopyFiles
set CopySource=%SrcFileDir%%SrcFile%
set DirCopyOldFilesDIR=%SrcFileDir%%PromotionDate%\%CASENumberForPromotion%\
set OldFileExtenxtion=.%CurrentDateTime%
echo. CopySource=%SrcFileDir%%SrcFile% to %DestinationFileDir% >> %dosDumpFileName%
For /F "tokens=*" %%n in ('dir %CopySource% /b') Do (
  set TCopyFile=%%n
  If Not Exist %DestinationFileDir%!TCopyFile! (
    echo. the file !TCopyFile! does not exists in %DestinationFileDir% >> %dosDumpFileName%
    echo. copy %SrcFileDir%!TCopyFile! %DestinationFileDir% >> %dosDumpFileName%
    copy %SrcFileDir%!TCopyFile! %DestinationFileDir% >> %dosDumpFileName%
  ) Else (
    echo. the file !TCopyFile! exists in %DestinationFileDir% >> %dosDumpFileName%
    call:CreateNewDirectory
    echo. copy %DestinationFileDir%!TCopyFile! to %DirCopyOldFilesDIR%OLD_!TCopyFile!%OldFileExtenxtion% >> %dosDumpFileName%
    copy %DestinationFileDir%!TCopyFile! %DirCopyOldFilesDIR%%OLDPrefix%!TCopyFile!%OldFileExtenxtion% >> %dosDumpFileName%
    echo. copy %SrcFileDir%!TCopyFile! %DestinationFileDir% >> %dosDumpFileName%
    copy %SrcFileDir%!TCopyFile! %DestinationFileDir% >> %dosDumpFileName%
  )
)
GOTO:EOF  
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 250 total points
ID: 36543285
Looks like it must be in the :ExecuteCommand sub?  What is in there?  Silly question but it isn't expecting "OperationName" not "opertionname" and therefore causing issue in the sub?

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36543298
Can you run it with echo off and show what goes on and add a few echos before after the DeployRuntime label, before the goto :eof, just befor and after the call.

If the call runs pop an echo at the start of that sub too perhaps.
0
 
LVL 8

Assisted Solution

by:Amitabh Singh
Amitabh Singh earned 250 total points
ID: 36543369
hi this is norml bat behavior when you use loop or if incide GOTO function

try to use if again in place of else
Example :
 
::-----------------------------------------------------------
:: Define DeployToRunTime
::-----------------------------------------------------------
:DeployToRunTime
if /i "%ApplicationOwner%" equ "IFS"  (
   echo this is for IFS >> %dosDumpFileName%
   echo set CitrixRunTimeLoc=%Citrix%%CitrixIFS% >> %dosDumpFileName%
   set DestinationFileDir=%Citrix%%CitrixIFS%
) 
if /i "%ApplicationOwner%" neq "IFS"(
   echo this is not for IFS >> %dosDumpFileName%
   echo this is for %ApplicationOwner% >> %dosDumpFileName%
   echo set CitrixRunTimeLoc=%Citrix%%CitrixIFS%%MACRunTimeLoc% >> %dosDumpFileName%
   set DestinationFileDir=%Citrix%%CitrixIFS%%MACRunTimeLoc%
   set OLDPrefix=OLD_RUNTIME_
   set OpertionName=CopyFiles
   call:ExecuteCommand
)
GOTO:EOF

Open in new window


try if its help else please provide full script then we able to help you !
0
 
LVL 2

Author Comment

by:jhacharya
ID: 36543398
::------------------------------------------------------------
:: record Start messaage
::------------------------------------------------------------
:StartMessaage
echo.Started %OpertionName% at %TIME% >> %dosDumpFileName%
GOTO:EOF

::------------------------------------------------------------
:: record End messaage
::------------------------------------------------------------
:EndMessaage
echo.this has ended %OpertionName% at %TIME% >> %dosDumpFileName%
GOTO:EOF


::-----------------------------------------------------------
:: Execute Commands
::-----------------------------------------------------------
:ExecuteCommand
call:StartMessaage
call:%OpertionName%
call:EndMessaage
set OpertionName=
GOTO:EOF

I use this to help track how long operations takes, I used this same process earlier in the batch file to call the copyfiles and it works the first time but not the second.

at the momnet I am relooking at my variables to see if something is not set properly.

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 2

Author Comment

by:jhacharya
ID: 36543405
@ECHO OFF
REM.-- Prepare the Command Processor
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

call:menuTOP
GOTO:EOF

::------------------------------------------------------------
:: SET Current DATE
::------------------------------------------------------------
:SETCurrentDate
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET CurrentDate=%mm%%dd%%yyyy%
GOTO:EOF


::------------------------------------------------------------
:: SET Current DATE_TIME
::------------------------------------------------------------
:SETCurrentDateTime
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
    for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do (
        set %%a=%%A&set %%b=%%B&set %%c=%%C))
set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
for /f "tokens=1-4 delims=:. " %%A in ("%time: =0%") do @set CurrentDateTime=%yy%%mm%%dd%%%A%%B%
GOTO:EOF

::------------------------------------------------------------
:: SET Current TIME
::------------------------------------------------------------
:SETCurrentTime
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
    for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do (
        set %%a=%%A&set %%b=%%B&set %%c=%%C))
set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
for /f "tokens=1-4 delims=:. " %%A in ("%time: =0%") do @set CurrentTime=%%A%%B%%C%%D
GOTO:EOF


::------------------------------------------------------------
:: Reset Global Parmeters
::------------------------------------------------------------
:ResetGlobalParmeters
call:SETCurrentDate
call:SETCurrentDateTime
call:SETCurrentTime
set PromotionDate=%CurrentDate%
set PromotionEnviroment=
set Citrix=
set Citrix1=\\aurora-citrix1\n$\Program Files\
set Citrix2=\\aurora-citrix2\n$\Program Files\
set Citrix3=\\aurora-citrix3\n$\Program Files\
set Citrix4=\\aurora-citrix4\n$\Program Files\
set CitrixIFS=
set CitrixMAC=
set dosDumpFileDir=
set dosDumpFilePrefix=Promotion_%PromotionDate%_DOS
set dosDumpFileExt=.LOG
set dosDumpFileName=
set dosSQLDumpFileName=
set dosSQLDumpFilePrefix=Promotion_%PromotionDate%_SQL
set Database=
set DbSchema=
set DbPassword=
set DbSQLConnStr=
set menuChoice1=
set menuChoice2=
set SrcFileDirForGeneric=
set SrcFileDir=
set SrcFile=
set DestinationFileDir=
set DbSQLSrcFile=
set SQLFILE_GENERIC=
set CASENumberForPromotion=
set MACApplication=
set ApplicationOwner=
set OLDPrefix=
GOTO:EOF


::------------------------------------------------------------
:: Show Global Paramteres
::------------------------------------------------------------
:ShowGlobalParmeters
echo.PromotionDate=%PromotionDate%
echo.dosDumpFileDir=%dosDumpFileDir%
echo.dosDumpFilePrefix=%dosDumpFilePrefix%
echo.dosDumpFileExt=%dosDumpFileExt%
echo.dosDumpFileName=%dosDumpFileName%
echo.dosSQLDumpFileName=%dosSQLDumpFileName%
echo.dosSQLDumpFilePrefix=%dosSQLDumpFilePrefix%
echo.Database=%Database%
echo.DbSchema=%DbSchema%
echo.DbPassword=%DbPassword%
echo.DbSQLConnStr=%DbSQLConnStr%
echo.menuChoice1=%menuChoice1%
echo.menuChoice2=%menuChoice2%
echo.SrcFileDir=%SrcFileDir%
echo.SrcFile=%SrcFile%
echo.DbSQLSrcFile=%DbSQLSrcFile%
echo.OpertionName=%OpertionName%
echo.PromotionType=%PromotionType%
echo.PromotionUSE=%PromotionUSE%
echo.SQLFILE_GENERIC=%SQLFILE_GENERIC%
echo.CASENumberForPromotion=%CASENumberForPromotion%
echo.PromotionEnviroment=%PromotionEnviroment%
echo.Citrix1=%Citrix1%
echo.Citrix2=%Citrix2%
echo.Citrix3=%Citrix3%
echo.Citrix4=%Citrix4%
echo.Citrix=%Citrix%
echo.DestinationFileDir=%DestinationFileDir%
echo.MACApplication=%MACApplication%
echo.ApplicationOwner=%ApplicationOwner%
echo.CitrixIFS=%CitrixIFS%
echo.CitrixMAC=%CitrixMAC%
echo.OLDPrefix=%OLDPrefix%
pause 20
GOTO:EOF

::------------------------------------------------------------
:: Define the source file directory
::------------------------------------------------------------
:SETSrcFileDir
set SrcFileDir=
echo.&set /p SrcFileDir=Enter in the directory in which the source files are located: ||GOTO:EOF
GOTO:EOF

::------------------------------------------------------------
:: Define the source file
::------------------------------------------------------------
:SETSrcFile
set SrcFile=
echo.&set /p SrcFile=Enter in the specific source file or enter to Ingore: ||GOTO:EOF
GOTO:EOF


::------------------------------------------------------------
:: Define the destination file directory
::------------------------------------------------------------
:SETDestinationFileDir
set DestinationFileDir=
echo.&set /p DestinationFileDir=Enter in the directory in which the source files are copied to: ||GOTO:EOF
GOTO:EOF


::------------------------------------------------------------
:: Define the Database source file
::------------------------------------------------------------
:SETDbSQLSrcFile
set DbSQLSrcFile=%SrcFileDir%%SrcFile%
echo.The SQL Srouce file is %DbSQLSrcFile% >> %dosDumpFileName%
GOTO:EOF

::------------------------------------------------------------
:: Define the connection string needed to log on the database
::------------------------------------------------------------
:SETDbSQLConnStr
set DbPassword=
echo.&set /p DbPassword=Please enter the %DbSchema% password for %Database% database: ||GOTO:EOF
SET DbSQLConnStr=%DbSchema%/%DbPassword%@%Database%
echo.sqlplus %DbSchema% %Database% >> %dosDumpFileName%
GOTO:EOF


::------------------------------------------------------------
:: Define how to log ON SQL onto the data base
::------------------------------------------------------------
:LogOnSQL
call:StartMessaage
echo.connecting onto %Database% at %TIME% >> %dosDumpFileName%
echo.%DbSQLConnStr% SrcFileDir=%SrcFileDir% SQLFILE_GENERIC=%SQLFILE_GENERIC% dosSQLDumpFilePrefix=%dosSQLDumpFilePrefix% dosDumpFileExt=

%dosDumpFileExt% SrcFileDir=%SrcFileDir% SrcFile=%SrcFile% >> %dosDumpFileName%
sqlplus %DbSQLConnStr% @%SrcFileDirForGeneric%%SQLFILE_GENERIC% %dosSQLDumpFilePrefix% %dosDumpFileExt% %SrcFileDir% %SrcFile% >

%dosSQLDumpFileName%
call:EndMessaage
GOTO:EOF



::------------------------------------------------------------
:: Define how to copy the files
::------------------------------------------------------------
:CopyFiles
set CopySource=%SrcFileDir%%SrcFile%
set DirCopyOldFilesDIR=%SrcFileDir%%PromotionDate%\%CASENumberForPromotion%\
set OldFileExtenxtion=.%CurrentDateTime%
echo. CopySource=%SrcFileDir%%SrcFile% to %DestinationFileDir% >> %dosDumpFileName%
For /F "tokens=*" %%n in ('dir %CopySource% /b') Do (
  set TCopyFile=%%n
  If Not Exist %DestinationFileDir%!TCopyFile! (
    echo. the file !TCopyFile! does not exists in %DestinationFileDir% >> %dosDumpFileName%
    echo. copy %SrcFileDir%!TCopyFile! %DestinationFileDir% >> %dosDumpFileName%
    copy %SrcFileDir%!TCopyFile! %DestinationFileDir% >> %dosDumpFileName%
  ) Else (
    echo. the file !TCopyFile! exists in %DestinationFileDir% >> %dosDumpFileName%
    call:CreateNewDirectory
    echo. copy %DestinationFileDir%!TCopyFile! to %DirCopyOldFilesDIR%OLD_!TCopyFile!%OldFileExtenxtion% >> %dosDumpFileName%
    copy %DestinationFileDir%!TCopyFile! %DirCopyOldFilesDIR%%OLDPrefix%!TCopyFile!%OldFileExtenxtion% >> %dosDumpFileName%
    echo. copy %SrcFileDir%!TCopyFile! %DestinationFileDir% >> %dosDumpFileName%
    copy %SrcFileDir%!TCopyFile! %DestinationFileDir% >> %dosDumpFileName%
  )
)
GOTO:EOF    


::------------------------------------------------------------
:: Define how to create Directory
::------------------------------------------------------------
:CreateNewDirectory
If Not Exist %DirCopyOldFilesDIR%NUL (
    echo. the drectory %DirCopyOldFilesDIR%  does not exists create one >> %dosDumpFileName%
    echo. md %DirCopyOldFilesDIR% >> %dosDumpFileName%
    md %DirCopyOldFilesDIR% >> %dosDumpFileName%
) Else (
    echo. the drectory %DirCopyOldFilesDIR%  does exist do nothing  >> %dosDumpFileName%
)
GOTO:EOF  



::------------------------------------------------------------
:: record Start messaage
::------------------------------------------------------------
:StartMessaage
echo.Started %OpertionName% at %TIME% >> %dosDumpFileName%
GOTO:EOF

::------------------------------------------------------------
:: record End messaage
::------------------------------------------------------------
:EndMessaage
echo.this has ended %OpertionName% at %TIME% >> %dosDumpFileName%
GOTO:EOF


::------------------------------------------------------------
:: record promotion Ended messaage
::------------------------------------------------------------
:PromotionEndMessaage
echo.this promotion has ended at %TIME% >> %dosDumpFileName%
echo.reseting batch parameters and going back to the main menu >> %dosDumpFileName%
echo. >> %dosDumpFileName%
GOTO:EOF


::------------------------------------------------------------
:: Define dosDumpFileName
::------------------------------------------------------------
:SetdosDumpFileName
set dosDumpFileName=%dosDumpFileDir%%dosDumpFilePrefix%_%CASENumberForPromotion%_%Database%_%DbSchema%%dosDumpFileExt%
echo. >> %dosDumpFileName%
echo.promotion started on %DATE% at %TIME% >> %dosDumpFileName%
echo.PromotionUSE=%PromotionUSE% >> %dosDumpFileName%
echo. PromotionType=%PromotionType% >> %dosDumpFileName%
echo. Database=%Database% >> %dosDumpFileName%
echo. DbSchema=%DbSchema% >> %dosDumpFileName%
echo. The Case number for this promotion is %CASENumberForPromotion% >> %dosDumpFileName%
echo. >> %dosDumpFileName%
GOTO:EOF


::------------------------------------------------------------
:: Define dosDumpFileName_CSharp
::------------------------------------------------------------
:SetdosDumpFileName_CSharp
set dosDumpFileName=%dosDumpFileDir%%dosDumpFilePrefix%_%CASENumberForPromotion%_%PromotionEnviroment%%dosDumpFileExt%
echo. >> %dosDumpFileName%
echo.promotion started on %DATE% at %TIME% >> %dosDumpFileName%
echo.PromotionUSE=%PromotionUSE% >> %dosDumpFileName%
echo. PromotionType=%PromotionType% >> %dosDumpFileName%
echo. Database=%Database% >> %dosDumpFileName%
echo. DbSchema=%DbSchema% >> %dosDumpFileName%
echo. The Case number for this promotion is %CASENumberForPromotion% >> %dosDumpFileName%
echo. >> %dosDumpFileName%
GOTO:EOF





::------------------------------------------------------------
:: Define dosSQLDumpFileName
::------------------------------------------------------------
:SetdosSQLDumpFileName
set dosSQLDumpFileName=%dosDumpFileDir%%dosSQLDumpFilePrefix%_%CASENumberForPromotion%_%Database%_%DbSchema%_%SrcFile%%dosDumpFileExt%
echo.The Log file for SQL file is %dosSQLDumpFileName% >> %dosDumpFileName%
GOTO:EOF


::------------------------------------------------------------
:: Define dosDumpFileDirectory
::------------------------------------------------------------
:SetdosDumpFileDir
set dosDumpFileDir=
echo.&set /p dosDumpFileDir=Enter in the directory where logs files are placed or enter for current directory:
GOTO:EOF



::------------------------------------------------------------
:: Define CASE Numer
::------------------------------------------------------------
:SETCASENumberForPromotion
echo.&set /p CASENumberForPromotion=Please enter the CASE Number for this promotion:
GOTO:EOF

::-----------------------------------------------------------
:: Execute Commands
::-----------------------------------------------------------
:ExecuteCommand
call:StartMessaage
call:%OpertionName%
call:EndMessaage
set OpertionName=
GOTO:EOF


::-----------------------------------------------------------
:: Define DeployToRunTime
::-----------------------------------------------------------
:DeployToRunTime
if /i "%ApplicationOwner%" equ "IFS"  (
   echo this is for IFS >> %dosDumpFileName%
   echo set CitrixRunTimeLoc=%Citrix%%CitrixIFS% >> %dosDumpFileName%
   set DestinationFileDir=%Citrix%%CitrixIFS%
) else (
   echo this is not for IFS >> %dosDumpFileName%
   echo this is for %ApplicationOwner% >> %dosDumpFileName%
   echo set CitrixRunTimeLoc=%Citrix%%CitrixIFS%%MACRunTimeLoc% >> %dosDumpFileName%
   set DestinationFileDir=%Citrix%%CitrixIFS%%MACRunTimeLoc%
   set OLDPrefix=OLD_RUNTIME_
   set OpertionName=CopyFiles
   pause 20
   call:ExecuteCommand
   pause 20
)
GOTO:EOF


::-------------------------------------------------------------
:: Define Menu Display Heading
::-------------------------------------------------------------
:menuDisplayHeading
cls
set OpertionName=
echo.================================================
echo. %Date% %PromotionUSE% %ApplicationOwner%
echo. %PromotionEnviroment% %PromotionType%
echo. %MACApplication%%Database% %DbSchema%
echo.================================================
echo.
GOTO:EOF

::-------------------------------------------------------------
:: Define menuTOP
::-------------------------------------------------------------
:menuTOP
call:ResetGlobalParmeters
call:menuDisplayHeading
echo. Promotion used for
echo.================================================
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuTOP_" "%~f0""') do echo.  %%B  %%C
set menuTOP0=
echo.&set /p menuTOP0=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menuTOP_%menuTOP0%
GOTO:EOF

::-----------------------------------------------------------
:: menuTOP functions follow below here
::-----------------------------------------------------------
:menuTOP_A   Admin Code Promomotion BE VERY CAREFUL
set PromotionUSE=ADMIN
echo.&call:menuCodeTYPE
GOTO:EOF

:menuTOP_N   Normal Code Promotion
set PromotionUSE=NORMAL
echo.&call:menuCodeTYPE
GOTO:EOF

:menuTOP_
exit
GOTO:EOF

:menuTOP_C   Clear Screen
cls
call:menuTOP
GOTO:EOF

:menuTOP_E   Exit
exit
GOTO:EOF

:menuTOP_H   Help
cls
echo.If you are unsure how to use this program please contact the IT Department. This program
echo.can effect the IFS and MAC applications. If you are not autherzied to use this program
echo.please exit now.
echo.
echo.The Normal use of this program is when promoting code as part of normal development for
echo.that option you should use option D.
echo.Be VERY CAREFUL using the ADMIN option, if you are unsure only use the Normal Option
echo.Thank You
pause 20
call:menuTOP
GOTO:EOF

::-------------------------------------------------------------
:: Define menuCodeTYPE
::-------------------------------------------------------------
:menuCodeTYPE
call:menuDisplayHeading
echo. Promotion choose Type of Code
echo.================================================
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuCodeTYPE_" "%~f0""') do echo.  %%B  %%C
set menuCodeTYPE0=
echo.&set /p menuCodeTYPE0=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menuCodeTYPE_%menuCodeTYPE0%
GOTO:EOF

::-----------------------------------------------------------
:: menuCodeTYPE functions follow below here
::-----------------------------------------------------------
:menuCodeTYPE_1   code promotion for Oracle Database
set PromotionType=OracleDatabase
echo.&call:%PromotionType%_Promotion
GOTO:EOF

:menuCodeTYPE_2   code promotion for CSharp
set PromotionType=CSharp
echo.&call:%PromotionType%_Promotion
GOTO:EOF

:menuCodeTYPE_3   code promotion for Crystal Reports
set PromotionType=CrystalReports
echo.the promotion for %PromotionType% has not yet been configured
echo.please contact IT to resolve this issue
pause 20
GOTO:EOF

:menuCodeTYPE_4   code promotion for SQL Server Database
set PromotionType=SQLServerDatabase
echo.the promotion for %PromotionType% has not yet been configured
echo.please contact IT to resolve this issue
pause 20
GOTO:EOF


:menuCodeTYPE_5   code promotion for Web Page
set PromotionType=WebPage
echo.the promotion for %PromotionType% has not yet been configured
echo.please contact IT to resolve this issue
pause 20
GOTO:EOF

:menuCodeTYPE_
exit
GOTO:EOF

:menuCodeTYPE_C   Clear Screen
cls
call:menuCodeTYPE
GOTO:EOF

:menuCodeTYPE_E   Exit
exit
GOTO:EOF

:menuCodeTYPE_H   Help
cls
echo.If you are unsure how to use this program please contact the IT Department. This program
echo.can effect the IFS and MAC applications. If you are not autherzied to use this program
echo.please exit now.
echo.Thank You
pause 20
call:menuCodeTYPE
GOTO:EOF


::-------------------------------------------------------------
:: Define OracleDatabase Promoiton
::-------------------------------------------------------------
:OracleDatabase_Promotion
call:menuDatabase
call:menuSchema
call:menuDisplayHeading
call:RunSQLPromotion
GOTO:EOF

::-----------------------------------------------------------
:: RunSQLPromotion defined here
::-----------------------------------------------------------
:RunSQLPromotion
call:SETCASENumberForPromotion
call:SetdosDumpFileDir
call:SetdosDumpFileName
set OpertionName=SETSrcFileDir
call:ExecuteCommand
set OpertionName=SETSrcFile
call:ExecuteCommand
set OpertionName=SETDbSQLSrcFile
call:ExecuteCommand
set OpertionName=SetdosSQLDumpFileName
call:ExecuteCommand
call:menuSingleORMultipleSQLSrc
set OpertionName=SETDbSQLConnStr
call:ExecuteCommand
set OpertionName=LogOnSQL
call:LogOnSQL
echo.CASE %CASENumberForPromotion% has been completed check (%dosDumpFileName%) log file for details
pause 20
set OpertionName=
call:menuCodeTYPE
GOTO:EOF

::-------------------------------------------------------------
:: Define cSharp Promoiton
::-------------------------------------------------------------
:CSharp_Promotion
call:menuEnvironment
call:menuApplicationOwner
call:menuDisplayHeading
call:SETCASENumberForPromotion
call:SetdosDumpFileDir
call:SetdosDumpFileName_CSharp
set OpertionName=SETSrcFileDir
call:ExecuteCommand
set OpertionName=SETSrcFile
call:ExecuteCommand
set OpertionName=SETDestinationFileDir
call:ExecuteCommand
set OLDPrefix=OLD_
set OpertionName=CopyFiles
call:ExecuteCommand
call:menuDeployToRunTime
echo.CASE %CASENumberForPromotion% has been completed check (%dosDumpFileName%) log file for details
set OpertionName=
call:menuCodeTYPE
GOTO:EOF


::-------------------------------------------------------------
:: Define Database menu
::-------------------------------------------------------------
:menuDatabase
call:menuDisplayHeading
echo. Choose a Database to promote to
echo.================================================
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuDatabase_" "%~f0""') do echo.  %%B  %%C
set menuDatabase0=
echo.&set /p menuDatabase0=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menuDatabase_%menuDatabase0%
GOTO:EOF

::-----------------------------------------------------------
:: menuDatabase functions follow below here
::-----------------------------------------------------------
:menuDatabase_D   DEV code promotion for Development Database
set Database=DEV
GOTO:EOF

:menuDatabase_T   TEST code promotion for Test Database
set Database=TEST
GOTO:EOF

:menuDatabase_S   STG code promotion for Staging Database
set Database=STG
call:SetdosDumpFileName
echo.Staging is not available for promotion of database code
echo.Staging is not available for promotion of database code >> %dosDumpFileName%
pause 20
call:menuDatabase
GOTO:EOF

:menuDatabase_
exit
GOTO:EOF

:menuDatabase_C   Clear Screen
cls
call:menuDatabase
GOTO:EOF

:menuDatabase_B   Go Back to Promotion Type Menu
cls
call:menuCodeTYPE
GOTO:EOF

:menuDatabase_H   Help
cls
echo.If you are unsure how to use this program please contact the IT Department. This program
echo.can effect the IFS and MAC applications. If you are not autherzied to use this program
echo.please exit now.
echo.Thank You
pause 20
GOTO:EOF

::-------------------------------------------------------------
:: Define Schema menu
::-------------------------------------------------------------
:menuSchema
call:menuDisplayHeading
echo.Choose a Schema for %Database% Database
echo.================================================
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuSchema_" "%~f0""') do echo.  %%B  %%C
set menuSchema0=
echo.&set /p menuSchema0=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menuSchema_%menuSchema0%
GOTO:EOF


::-----------------------------------------------------------
:: menuSchema functions follow below here
::-----------------------------------------------------------

:menuSchema_1   Promote code using MAC
set DbSchema=MAC
GOTO:EOF

:menuSchema_2   Promote code using MACAPP
set DbSchema=MACAPP
GOTO:EOF

:menuSchema_3   Promote code using IFSAPP
set DbSchema=IFSAPP
GOTO:EOF

:menuSchema_
call:menuSchema
GOTO:EOF

:menuSchema_C   Clear Screen
cls
GOTO:menuSchema

:menuSchema_B   Go Back to Database Menu
cls
call:menuDatabase
GOTO:EOF



::-------------------------------------------------------------
:: Define Single or Multiple source file
::-------------------------------------------------------------
:menuSingleORMultipleSQLSrc
set menuSingleORMultipleSQLSrc0=
echo.
echo.Are you using multiple template? hit enter for default:
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuSingleORMultipleSQLSrc_" "%~f0""') do echo.  %%B  %%C
echo.&set /p menuSingleORMultipleSQLSrc0=
echo.&call:menuSingleORMultipleSQLSrc_%menuSingleORMultipleSQLSrc0%
GOTO:EOF


::-----------------------------------------------------------
:: menuSingleORMultipleSQLSrc functions follow below here
::-----------------------------------------------------------

:menuSingleORMultipleSQLSrc_Y   Yes
set SQLFILE_GENERIC=%SrcFile%
set SrcFileDirForGeneric=%SrcFileDir%
echo. The Sql file running is %SrcFileDirForGeneric%%SQLFILE_GENERIC% >> %dosDumpFileName%
GOTO:EOF

:menuSingleORMultipleSQLSrc_N   No
set SQLFILE_GENERIC=generic_single
set SrcFileDirForGeneric=\\aurora-util01\IT-DEV$\Deployment\
echo. The Sql file running is %SrcFileDirForGeneric%%SQLFILE_GENERIC% >> %dosDumpFileName%
GOTO:EOF

:menuSingleORMultipleSQLSrc_   Defualt is No
set SQLFILE_GENERIC=generic_single
set SrcFileDirForGeneric=\\aurora-util01\IT-DEV$\Deployment\
echo. The Sql file running is %SrcFileDirForGeneric%%SQLFILE_GENERIC% >> %dosDumpFileName%
GOTO:EOF



::-------------------------------------------------------------
:: Define menuEnvironment
::-------------------------------------------------------------
:menuEnvironment
call:menuDisplayHeading
echo. Choose the Envrioment to promote into
echo.================================================
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuEnvironment_" "%~f0""') do echo.  %%B  %%C
set menuEnvironment0=
echo.&set /p menuEnvironment0=Please choose environment to promote code into: ||GOTO:EOF
echo.&call:menuEnvironment_%menuEnvironment0%
GOTO:EOF



::-----------------------------------------------------------
:: menuEnvironment functions follow below here
::-----------------------------------------------------------
:menuEnvironment_D   DEV  Development
set PromotionEnviroment=DEV
set Citrix=%Citrix4%
set CitrixIFS=IFS Dev Applications\
set CitrixMAC=Mitutoyo America Dev\
GOTO:EOF

:menuEnvironment_T   TEST Test
set PromotionEnviroment=TEST
set Citrix=%Citrix4%
set CitrixIFS=IFS Test Applications\
set CitrixMAC=Mitutoyo America Test\
GOTO:EOF

:menuEnvironment_S   STG  Staging
set PromotionEnviroment=STG
set Citrix=%Citrix4%
set CitrixIFS=IFS STG Applications\
set CitrixMAC=Mitutoyo America STG\
GOTO:EOF

:menuEnvironment_
call:menuEnvironment
GOTO:EOF

:menuEnvironmen_B   Go Back to Promotion Type Menu
cls
call:menuCodeTYPE
GOTO:EOF



::-------------------------------------------------------------
:: Define menuApplicationOwner
::-------------------------------------------------------------
:menuApplicationOwner
call:menuDisplayHeading
echo. What type of application are you promoting
echo.================================================
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuApplicationOwner_" "%~f0""') do echo.  %%B  %%C
set menuApplicationOwner0=
echo.&set /p menuApplicationOwner0=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menuApplicationOwner_%menuApplicationOwner0%
GOTO:EOF

::-----------------------------------------------------------
:: menuApplicationOwner functions follow below here
::-----------------------------------------------------------
:menuApplicationOwner_I   IFS
set ApplicationOwner=IFS
GOTO:EOF

:menuApplicationOwner_M   MAC
set ApplicationOwner=MAC
call:menuMACApplication
GOTO:EOF

:menuApplicationOwner_H   Help
echo.
echo.If you are unsure how to use this program please contact the IT Department. This program
echo.can effect the IFS and MAC applications. If you are not autherzied to use this program
echo.please exit now.
echo.Thank You
echo.
pause 20
call:menuApplicationOwner
GOTO:EOF




::-------------------------------------------------------------
:: Define menuMACApplication
::-------------------------------------------------------------
:menuMACApplication
call:menuDisplayHeading
echo. What MAC application are you promoting
echo.================================================
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuMACApplication_" "%~f0""') do echo.  %%B  %%C
set menuMACApplicationr0=
echo.&set /p menuMACApplication0=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menuMACApplication_%menuMACApplication0%
GOTO:EOF

::-----------------------------------------------------------
:: menuApplicationOwner functions follow below here
::-----------------------------------------------------------
:menuMACApplication_1   Create EAN
set MACApplication=Create EAN
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_2   Doc Processor
set MACApplication=Doc Processor
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_3   EDI Window
set MACApplication=EDI Window
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_4   Inventory Counting
set MACApplication=Inventory Counting
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_5   Lending
set MACApplication=Lending
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_6   Packing Slip
set MACApplication=Packing Slip
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_7   PPL List
set MACApplication=PPL List
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_8   Print UPC Barcode
set MACApplication=Print UPC Barcode
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_9   Receiving Barcode Client
set MACApplication=Receiving Barcode Client
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_10   Report Picking BC
set MACApplication=Report Picking BC
set MACRunTimeLoc=
GOTO:EOF

:menuMACApplication_11   Stock Check
set MACApplication=Stock Check
set MACRunTimeLoc=Stockcheck
GOTO:EOF

:menuMACApplication_12   win Education
set MACApplication=win Education
set MACRunTimeLoc=
GOTO:EOF


:menuMACApplication_H   Help
echo.
echo.If you are unsure how to use this program please contact the IT Department. This program
echo.can effect the IFS and MAC applications. If you are not autherzied to use this program
echo.please exit now.
echo.Thank You
echo.
pause 20
call:menuApplicationOwner
GOTO:EOF

::-------------------------------------------------------------
:: Define menuDeployToRunTime
::-------------------------------------------------------------
:menuDeployToRunTime
call:menuDisplayHeading
echo. You have promoted code to the Deployment folders
echo. Do you want to deploy promotion to the Run time Locations?
echo.================================================
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menuDeployToRunTime_" "%~f0""') do echo.  %%B  %%C
set menuDeployToRunTime0=
echo.&set /p menuDeployToRunTime0=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menuDeployToRunTime_%menuDeployToRunTime0%
GOTO:EOF

::-----------------------------------------------------------
:: menuApplicationOwner functions follow below here
::-----------------------------------------------------------
:menuDeployToRunTime_Y   Yes
echo.Promoting code to run time CITRIX locations >> %dosDumpFileName%
call:DeployToRunTime
GOTO:EOF

:menuDeployToRunTime_N   No
echo.Do NOT DEPLOY TO CITRIX RUN TIME LOCATIONS >> %dosDumpFileName%
GOTO:EOF

0
 
LVL 2

Author Comment

by:jhacharya
ID: 36543550
I tried your fix but now i get the following error

The syntax of the command is incorrect.

::-----------------------------------------------------------
:: Define DeployToRunTime
::-----------------------------------------------------------
:DeployToRunTime
if /i "%ApplicationOwner%" equ "IFS"  (
   echo this is for IFS >> %dosDumpFileName%
   echo set CitrixRunTimeLoc=%Citrix%%CitrixIFS%\ >> %dosDumpFileName%
   set DestinationFileDir=%Citrix%%CitrixIFS%
)
if /i "%ApplicationOwner%" neq "IFS"(
   echo this is not for IFS >> %dosDumpFileName%
   echo this is for %ApplicationOwner% >> %dosDumpFileName%
   echo set CitrixRunTimeLoc=%Citrix%%CitrixIFS%%MACRunTimeLoc% >> %dosDumpFileName%
   set DestinationFileDir=%Citrix%%CitrixIFS%%MACRunTimeLoc%
   set OLDPrefix=OLD_RUNTIME_
   set OpertionName=CopyFiles
   call:ExecuteCommand
)
GOTO:EOF
0
 
LVL 2

Author Comment

by:jhacharya
ID: 36543569

I know that the issue is at the point of calling CopyFiles

set OpertionName=CopyFiles
   call:ExecuteCommand

But I call this same function ealier in the process and it works fine. maybe something need to be reste when calling for the second time
0
 
LVL 2

Assisted Solution

by:jhacharya
jhacharya earned 0 total points
ID: 36545258
ARGHHHHH!!!

ok im stupid, the directory sometimes would have a space in the name so in dos i need to put this in quotes...

Once I did that the program works fine

0
 
LVL 2

Author Closing Comment

by:jhacharya
ID: 36565489
while none of the people who answered actually got the answer, It did help me in the way i re-approached the problem, so i am awrding the points to both people
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36545304
In that option it will be the lack of space here before the (:

if /i "%ApplicationOwner%" neq "IFS"(

Still can't see why the original doesn't work at the mo. too complicated to simulate running it as is.

Steve
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now