Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

locating ip address in the line of a file

Status
Not open for further replies.

sweetie5583

Programmer
Feb 15, 2003
1
US
I need to suummarize a file by locating the ip address from a line in the form of
ssi sqn ssn mss ip mid chg dsi
where all but the sqn and ssn are guarrenteed to be there.
how do I go about finding the ip?
 
i'm not sure what the other acronyms stand for... but i assume the ip is the only one that has 4 series of numbers with '.' between them? you can parse the file using StreamTokenizer, and look for that sort of pattern. Take each the string value of each token (which i'm assuming are seperated by whitespace?), see if it has a '.' in it... if it doesn't, then go to the next token.

If each record is on a seperate line, then you can increase efficiency by only checking between the 3rd and 5th entries (as nothing before or after could be the ip). Liam Morley
lmorley@gdc.wpi.edu
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top