|
Answer» Hi,
I am new to batch programming. I have a requirement where in I have to one map to a server and change the password for a product installed on that server there are more then one product on that one server.
I need some basics to get clear
for /f %%I in (dctm5dev.INI) do call change_dctm_passwd.bat %%I %1 %2
can some help me to get some tutorials which has these commands like
for /f ( i dont know the meaning of /f but i can guess from the code that its says for each line in the file ........ but i want to know the correct meaning .... no guesses)
similary
for /f "tokens=1,2" %%I in (%dctm_server%.ini) do call change_db_passwd.bat %%I %%J
i would like some one ot tell me how does token things work.
Any help would be appreciated
Raj
The FOR command can be used for parsing, running a command repetitvely or reading input or depending on how it's written any combination thereof. They can also be NESTED. Note: %% variables do not exist outside the scope of the FOR statement.
The /f switch indicates what data format the FOR statement will be acting on.
for /f %%a in (file-set) for /f %%a in ('command') for /f %%a in ("string")
Note the use of the quotes. (no quotes is a file-set; one quote is a command; two quotes are a string value)
The tokens are stranger animals. In general they are sequenced single letters (case sensitive, %%a is not the same as %%A). The first token is the one you use in the FOR statement, the others are relative to their sequence in the alphabet.
Example:
for /f "tokens=1-3" %%a
%%a is token 1 %%b is token 2 %%c is token 3
for /f "tokens=1-3" %%i
%%i is token 1 %%j is token 2 %%k is token 3
It gets even stranger if you skip a token:
Example:
for /f "tokens=2-3" %%c
The first value exists, but it's second value that is assigned to the %%c token.
Typing FOR /? might help, but the Microsoft EXPLANATION is more convoluted than mine. Depending on your OS, there are other switches (/D, /L, & /R) and then there is skip= and delims=.
Good LUCK. 8-)
|