The following script opens a process pipeline and reads its output one line at a time.
#!/usr/bin/tclsh
set input [open "|ls /"]
while {[gets $input line] >= 0} {
	puts $line
}
close $input
The next script dumps a webpage
set s [socket 127.0.0.1 8080]
fconfigure $s -buffering line
puts $s "GET /languages.html\n"
set page [read $s]
close $s
puts $page