Named pipes using MKS Toolkit

I'm not sure whether or not this question really belongs in this forum and will accept rebuke should I have mistakenly put it in the wrong place (hopefully the rebuke will be accompanied by an answer, though)

I wish to implement named pipe communication between two process using MKS Toolkit. I have used the "mkfifo" command to create the named pipe in the appropriate directory, but I cannot find a way, from the command line, to write to the pipe without destroying it. If I do something like "ls > mypipe.fifo" then the pipe is destroyed and the mypipe.fifo is converted to a normal text file.

I found a reference to using the MKS call to popen() in order to open a pipe, but am not able (allowed) to write and install a user-written c program on the MKS installation. Thus I am looking for some method of writing to the named pipe using a command line call and haven't found anything in the documentation or by searching the web.

Try this:

#!/bin/bash
# reader.sh
pipe=/tmp/mypipe
trap "rm -f $pipe" EXIT

if [[ ! -p $pipe ]]; then
    mkfifo $pipe
fi

while true
do
    if read line <$pipe; then
        if [[ "$line" == 'quit' ]]; then
            break
        fi
        echo $line
    fi
done

#!/bin/bash
# writer.sh
pipe=/tmp/mypipe

if [[ ! -p $pipe ]]; then
    echo "Reader not running"
    exit 1
fi


if [[ "$1" ]]; then
    echo "$1" >$pipe
else
    echo "Hello from $$" >$pipe
fi

usage:

sh ./reader.sh &
./writer.sh "hello"
./writer.sh
./writer.sh "quit"

Is that what you meant? This works in "standard" bash - I don't have mks so I don't know if bash under mks is complete implementation.

Hello Jim,

thanks for the quick response, but unfortunately every redirection to write to the pipe, be it through "echo" or "cat", changes the file type from a pipe to a normal sequential in the MKS toolkit. I've tried with DOS, sh and bash and the behaviour is the same in all cases.