Creating named pipe using tcl.

1 view
Skip to first unread message

Chandra Sekhar.K

unread,
Jul 29, 1998, 3:00:00 AM7/29/98
to cse...@cisco.com
Hi,

Any one of you can tell me

* How to create a named pipe in Tcl
* Can more than one process put data into a named pipe at the same
time.
* How to write and read the data from it.

Thanks
Chandra.

Michael Schumacher

unread,
Jul 29, 1998, 3:00:00 AM7/29/98
to
Chandra Sekhar.K <cse...@cisco.com> wrote:
: * How to create a named pipe in Tcl

Just use "exec mknod ...". Don't expect this to be cross-plattform.

: * Can more than one process put data into a named pipe at the same
: time.

Yes, but you need to implement some kind of protocol to find out which
process sent what; this doesn't work out of the box.

: * How to write and read the data from it.

open/gets/puts are your friends.


mike

lvi...@cas.org

unread,
Jul 29, 1998, 3:00:00 AM7/29/98
to

According to Michael Schumacher <mi...@hightec.saarlink.de>:
:Chandra Sekhar.K <cse...@cisco.com> wrote:
:: * Can more than one process put data into a named pipe at the same
:: time.
:
:Yes, but you need to implement some kind of protocol to find out which
:process sent what; this doesn't work out of the box.

One also needs to be sure they understand that writes to a named pipe,
just like any other pipe, will hang while the pipe is full and I seem
to recall return errors if there is no reader on the other end...

Someone who is familar with writing pipe code in perl or C will be
comforted to know that they work the same in tcl. If the writer is
not comfortable writing pipe code in shell or C then I suspect finding
general info about writing such code would be useful.

Anyone have useful tutorials to writing pipe code?

--
<URL:mailto:lvi...@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.

Don Libes

unread,
Jul 29, 1998, 3:00:00 AM7/29/98
to
In article <6pn873$ns5$1...@srv38s4u.cas.org> lvi...@cas.org writes:
According to Michael Schumacher <mi...@hightec.saarlink.de>:
:Chandra Sekhar.K <cse...@cisco.com> wrote:
:: * Can more than one process put data into a named pipe at the same
:: time.
:
:Yes, but you need to implement some kind of protocol to find out which
:process sent what; this doesn't work out of the box.

One also needs to be sure they understand that writes to a named pipe,
just like any other pipe, will hang while the pipe is full and I seem
to recall return errors if there is no reader on the other end...

Someone who is familar with writing pipe code in perl or C will be
comforted to know that they work the same in tcl. If the writer is
not comfortable writing pipe code in shell or C then I suspect finding
general info about writing such code would be useful.

Anyone have useful tutorials to writing pipe code?

There are extensive explanations of named pipes in my book and in the
example directory of the Expect distribution. For example, the
'dislocate' example uses them extensively.

Michael Schumacher <mi...@hightec.saarlink.de> wrote:
>Chandra Sekhar.K <cse...@cisco.com> wrote:

>: * How to create a named pipe in Tcl
>Just use "exec mknod ...". Don't expect this to be cross-plattform.

I've had a lot of experience trying to do this portably (at least on
UNIX). The book uses the following procedure for creating them:

proc mkfifo {f} {
if {[file exists $f]} return

if {0==[catch {exec mkfifo $f}]} return ;# POSIX
if {0==[catch {exec mknod $f p}]} return
if {0==[catch {exec /usr/etc/mknod $f p}]} return ;# Sun
if {0==[catch {exec /etc/mknod $f p}]} return ;# AIX, Cray
error "Couldn't figure out how to make a fifo - where is mknod?"
}

-Don

Reply all
Reply to author
Forward
0 new messages