Computing.Net > Forums > Windows 2000 > Parsing strings in a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Parsing strings in a file

Reply to Message Icon

Name: v_ajay31
Date: June 26, 2007 at 01:07:10 Pacific
OS: win2k + sp4
CPU/Ram: 256
Comment:

Plese tell me what is the problem with code below, it is not giving any output, I need a number which is written next to the string "PORT" in myfile.txt file.
For /F "eol=* tokens=2,3* delims= " %%a in (myfile.txt) Do (
IF "%%a"=="PORT" (
@echo %%b
) ELSE (
@echo %%a
)




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 26, 2007 at 02:04:07 Pacific
Reply:

Post a few lines of myfile.



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: v_ajay31
Date: June 26, 2007 at 02:42:02 Pacific
Reply:

A few lines from myfiles.txt

EVERY HOST host_name
EVERY KEEP_DATA Y
EVERY PORT 3252


0

Response Number 3
Name: Mechanix2Go
Date: June 26, 2007 at 03:13:59 Pacific
Reply:

::== fPORT.bat
:: spit out PORT number

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (myfile.txt) do (
echo %%a | find "PORT" > nul
if not errorlevel 1 set str=%%a && call :sub1
)
goto :eof

:sub1

for /f "tokens=3 delims= " %%n in ('echo !str!') do (
echo %%n
)
goto :eof
::==


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 4
Name: v_ajay31
Date: June 26, 2007 at 03:43:02 Pacific
Reply:

Great! Thanks a lot.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Parsing strings in a file

Search for string in a file www.computing.net/answers/windows-2000/search-for-string-in-a-file/59897.html

change a line in a file using CMD www.computing.net/answers/windows-2000/change-a-line-in-a-file-using-cmd/63947.html

how to send an IP address to a file www.computing.net/answers/windows-2000/how-to-send-an-ip-address-to-a-file/19848.html