Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tk/Tcl



On Mon, 23 Sep 1996, pal wrote:

pal>Hi All
pal>Sorry for being off the Topic here
pal>
pal>But I'm trying to read and write a Piped Process
pal>within Tcl 
pal>
pal>      set f1 [open {|MYPROG weak.spd} w+]  
pal>I can write
pal>      puts $f1 ls   
pal>
pal>But reading does not seem to work
pal>      gets $f1 var
pal>
pal>any suggestions 

The following segment of code reads correctly from a pipe, so I suspect
that it maybe the use of the 'w+' access mode.  Checking the manual says
that:

r+	Open for reading and writing; the file must exist.
w+	Open for reading and writing. Truncate the file if it already
	exists, otherwise create a new empty file.

So I guess the truncate on a pipe maybe the problem.
Hope that helps,
Paul.

#!/usr/local/bin/tclsh

set f1 [open {|cat /etc/motd} r+]
while {![eof $f1]} {
        gets $f1 var
        puts $var
}
close $f1

pal>leo
pal>-----------------------------------------------------------------
pal>a word from the sponsor will appear below
pal>-----------------------------------------------------------------
pal>The TLUG mailing list is proudly sponsored by TWICS - Japan's First
pal>Public-Access Internet System.  Now offering 20,000 yen/year flat
pal>rate Internet access with no time charges.  Full line of corporate
pal>Internet and intranet products are available.   info@example.com
pal>Tel: 03-3351-5977   Fax: 03-3353-6096
pal>

--------------------------------------------------------------------------
mailto:paulg@example.com     phoneto:81-3-3351-5977     faxto:81-3-3353-6096
The students learn that effective action arises out of silence and a clear
sense of being.  In this they find a source of peace.  They  discover that
the person who is down-to-earth can do what needs doing  more  effectively
than the person who is merely busy.  - Lao Tzu's    "Tao Te Ching"   500BC
--------------------------------------------------------------------------


-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links