I am trying to create batch script which can take multiple inputs from user & then create file & save all the inputs in that file. Below is the code i created but it id not working. Can you please help me.
@echo off
set /P inst=Enter number of installation:
set /A ha_inst=%inst%
FOR /L %%i IN (1,1,%ha_inst%) DO (
set /P hostname= Enter host name:
set /P sid=Enter SID:
echo. >C:\Users\smnadm\Desktop\hdbinst.cfg_%%i
(
echo # Local Host Name
echo hostname=%hostname%
echo # SAP HANA System ID
echo sid=%sid%
) >C:\Users\smnadm\Desktop\%hdbinst.cfg_%%i%
)
Thanks
In last line of code you write into the file
C:\Users\smnadm\Desktop\%hdbinst.cfg_%%i%
However the variable %hdbinst.cfg_% has never been set in your code. You might want to use hdbinst.cfg_%%i instead?
The following code works for me:
@echo off
setlocal ENABLEDELAYEDEXPANSION
set /P inst=Enter number of installation:
set /A ha_inst=%inst%
FOR /L %%i IN (1,1,%ha_inst%) DO (
set /P hostname=Enter host name:
set /P sid=Enter SID:
echo. >C:\temp\hdbinst.cfg_%%i
echo # Local Host Name >>C:\temp\hdbinst.cfg_%%i
echo hostname=!hostname! >>C:\temp\hdbinst.cfg_%%i
echo # SAP HANA System ID >>C:\temp\hdbinst.cfg_%%i
echo sid=!sid! >>C:\temp\hdbinst.cfg_%%i
)
writing in the Directory c:\\temp however.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.