i'm having problem calling specific section of batch script. goal run script , have install given executables , run commands:
@echo off echo 1. 32-bit echo 2. 64-bit set /p install="please choose correct installation: " set /p proxy="enter proxy gateway path if applicable environment: " 2>nul call :case_%install% if errorlevel 1 call :error rem case_%install% or error returns here echo done. pause exit \b :case_1 rem install nodejs 32-bit call node-v4.4.7-x86.msi rem install ruby call rubyinstaller-2.3.1.exe goto next_task :case_2 rem install nodejs 64-bit call node-v4.4.7-x64.msi rem install ruby call rubyinstaller-2.3.1-x64.exe goto next_task :next_task rem install sass css precompiler (v3.4.19) call gem install sass --http-proxy %proxy% rem install compass css plug-in (v1.0.3) call gem install compass --http-proxy %proxy% rem run node package install cd .. if not "%proxy%"=="" ( call npm config set proxy %proxy% call npm config set https-proxy %proxy% ) call npm install rem instal grunt globally call npm install -g grunt rem install jshint globally because of warning call npm install -g jshint goto end_case :error echo unable complete installation of tools goto end_case :end_case ver > nul goto:eof
this execute either case_1
or case_2
perfectly, depending on user chooses. nodejs installed, , ruby. then, when reaches end of 1 of sections, output:
done. press key continue . . .
the script never follows goto
run next_task
, , never installs sass or compass , doesn't run npm commands.
i have noticed running script twice , skipping nodejs installation on second run executes
next_task
section correctly... - leads me believe there's sort of timing issue going on here.
other things have tried:
- replacing
goto
scall
s (does not behave correctly) - replacing section names referenced
goto
use format:{section}
(no change) - replacing
call
s before node , ruby executablestart /wait
(doesn't seem makes difference)
so, i'm stumped. appreciated.
i ended solving problem (using workaround) breaking script 2 separate scripts. unfortunately, i'm unable call 1 script other , gem
, npm
commands set (even through use of start
create new environment, surprising me), solution. @aschipfl pointing out unnecessary use of call
when referencing executables.
install_tools.bat (run first)
@echo off echo 1. 32-bit echo 2. 64-bit set /p install="please choose correct installation: " 2>nul call :case_%install% if errorlevel 1 call :error rem case_%install% returns here pause exit :case_1 rem install nodejs 32-bit start "" /w node-v4.4.7-x86.msi rem install ruby rubyinstaller-2.3.1.exe goto success :case_2 rem install nodejs 64-bit start "" /w node-v4.4.7-x64.msi rem install ruby rubyinstaller-2.3.1-x64.exe goto success :error echo. echo unable complete installation of tools goto end_case :success echo. echo done. please run init_tools.bat. goto end_case :end_case ver > nul goto:eof
init_tools.bat (run second)
@echo off set /p proxy="enter proxy gateway path if applicable environment: " rem install sass css precompiler (v3.4.19) call gem install sass --http-proxy %proxy% rem install compass css plug-in (v1.0.3) call gem install compass --http-proxy %proxy% rem run node package install cd .. if not "%proxy%"=="" ( call npm config set proxy %proxy% call npm config set https-proxy %proxy% ) call npm install rem instal grunt globally call npm install -g grunt rem install jshint globally because of warning call npm install -g jshint echo. echo tools initialized. pause exit
Comments
Post a Comment