Re: extract hostnames



Michael A. Cleverly wrote:
On Thu, 28 Sep 2006, tom wrote:


im looking for a script that can extract hostnames from a
list(txt,html) like this:

the-roadside.com 3 43197 1( 0)
202.218.17.12-OK
[etc...]


set hosts [list]
set fp [open path/to/the/file]
while {[gets $fp line] != -1} {
lappend hosts [lindex $line 0]
}
close $fp
puts $hosts

Michael

That only works if the data is guaranteed to be a well-formed series of newline separated tcl lists. Real world data is notorious for being ignorant of that requirement.

--
Bryan Oakley
http://www.tclscripting.com
.



Relevant Pages