Extraction of Multiple Lines Using Batch Prog

January 2, 2011 at 22:24:24
Specs: Windows XP
How can i extract multiple lines from a batch file?

Actually i have put some user id and password in a notepad file and want to use them in my batch program. How can i select only a specific id and password?
Do i have to use For Loop , if yes then how?

I have put data in the notepad file like below :-
ID1 Password1
ID2 Password2
...

Please help me with this.


See More: Extraction of Multiple Lines Using Batch Prog

Report •

#1
January 2, 2011 at 22:46:18
How will the batch know which line is needed?


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
January 2, 2011 at 22:47:22
What i tried to do is below -

@echo off
FOR /F "tokens=1-3" %%G IN (sample.txt) DO (
if %%G == 'XYZ' and %%H == 'ABC' and %%I == 'PQR' then
SET id=%%G
SET pass=%%H
SET db=%%I
SET login=%id%/%pass%@%db%

goto :1
end if

)

:1

c:\oracle\ora92\bin\sqlplus %login% "@C:\Documents and Settings\vyom\Desktop\test.sql"

This is working fine. But, do i have to call the initial script again and again for every file or can i make it a utility program and call it for every program where i want to use it.

If there is some other approach to do the above thing please help me with that , and how to make it a utility program.


Report •

#3
January 2, 2011 at 23:26:51
"This is working fine"

I can't imagine how but I'll stay tuned.


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions

#4
January 3, 2011 at 00:10:55
Is there any other way to do the above , or is it ok.
Can you help how can i make the initial script i.e. the for loop code as a utility program so that i don't have to write it again and again for avery such proram mentioned.

Report •

Ask Question