Trying to read username and password from text file, each username and password separated on new line in txt file.
Not able to iterate over the array and get first element and second element from array and assign to varUser
and varPass
, then third and fourth and so on. These two temporary variables will be used as parameter for winScp console for login sftp server. The script.txt file has command to connect that takes varUser
and varPass
as parameter from batch file.
rem 1. reading text file and filling in array
for /F "usebackq delims=" %%a in (file.txt) do (
set /A i+=1
call echo i=%%i%%
call set array[%%i%%]=%%a
call set lastIndex=%%i%%
)
rem 2. reading array values from filled array and store in temp varUser and varPass
set /a i=0
set /a j=1
for /L %%i in (1,2,%lastIndex%) do (
call echo %%array[%%i]%%
set varUser=%%array[%%i]%%
set varPass=%%array[%%j]%%
winscp.com /script=script.txt /parameter put %varUser%,%varPass%
set /a j+=1
)