build: Update autosetup to v0.6.6-8-g062d650
[jimtcl.git] / examples / popen.tcl
blobf330fc9dedec8213deda0af39b2cd89b6638b53c
1 # Internally, open "|..." calls out to popen from tclcompat.tcl
3 # This code is compatible with Tcl
5 # Write to a pipe
6 set f [open |[list cat | sed -e "s/line/This is line/" >temp.out] w]
7 puts "Creating temp.out with pids: [pid $f]"
8 foreach n {1 2 3 4 5} {
9 puts $f "line $n"
11 close $f
13 # Read from a pipe
14 set f [open "|cat temp.out"]
15 puts "Reading temp.out with pids: [pid $f]"
16 while {[gets $f buf] >= 0} {
17 puts $buf
19 close $f
20 file delete temp.out