batch file - ( goto was unexpected this time error -



batch file - ( goto was unexpected this time error -

my code below throwing error.please help.i new batch file scripts.it showing syntax error , (goto unexpected time error. motive create batch file take parameter user.based on parameter, perform tasks. if input sql, execute sql script.if input foldercreation, create new folder.

@echo off cls set /p filetype=type of file : if "%filetype%==sql" (goto sql) if "%filetype%==txt" (goto text) if "%filetype%==bat" (goto bat) if "%filetype%==foldercreation" (goto foldercreation) if "%filetype%==ftp" (goto ftp) :sql set /p sname=server name : set /p dbname=database name : if exist _deploy.txt del _deploy.txt @echo on sqlcmd -s %sname% -e -d %dbname% -i -i "d:\script\execute_script.sql" >>_deploy.txt 2>&1 @notepad _deploy.txt exit /b :text if exist _deploy.txt @echo on move /-y "d:\artifacts\art1\test1.txt" "d:\artifacts\art2\">>_deploy.txt 2>&1 @notepad _deploy.txt exit /b :bat if exist _deploy.txt @echo on phone call testbatchcreatefolder.bat>>_deploy.txt 2>&1 @notepad _deploy.txt move /-y "d:\artifacts\art1\testbatchcreatefolder.bat" "d:\artifacts\art2\" exit /b :foldercreation set /p mypath=path please : set /p myfoldername=folder name : set folder_path=%mypath%\%myfoldername% md "%folder_path%" exit /b :ftp if exist _deploy.txt @echo on move /-y "d:\artifacts\art1\test2.txt" "d:\artifacts\art2\">>_deploy.txt 2>&1 @notepad _deploy.txt exit /b pause set /p delexit=press come in key exit...: :end

if "%filetype%==sql" (goto sql) ^...............^ = 1 string

so previous code equivalent

if "this not valid" (goto sql)

in if command need condition. if needs compare 2 strings should be

if "%filetype%"=="sql" (goto sql) ^..........^ ^...^

when parser replaces variable reference value end 1 quoted string in each side of == operator

this alter should made in similar lines.

also, lines

if exist _deploy.txt

are missing command part. if intention execute block of code next if, should be

if exist _deploy.txt ( here code execute if file exist )

batch-file if-statement syntax goto

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -