How do I find and read lines from text files? Batch -


i need thing read in text file goes follows:


nicholas password1

micheal password2

myname password3


i want batch file detect if variable %fname% (nicholas) exists. after that, need find out if %pword%(password1) after %fname%

you can use for command this:

set auth_ok=0  /f "tokens=1-2" %%a in (passwords.txt) (     if "%%a"=="%fname%" (         if "%%b"=="%pword%" (             set auth_ok=1         )     ) )  if %auth_ok%==1 (     echo access granted. ) else (     echo access denied. ) 

that's assuming in batch file. if command line have use single % on loop variables instead of double (%%).

i should mention case-sensitive.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -