Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : Named Pipes : UNIX named pipes : UNIX named pipe examples : Example 1: creating and using a named pipe from the shell
Example 1: creating and using a named pipe from the shell
In the i-pipex1 example, the cat command sets up a message handler routine and the echo command acts as the requestor.
# Named Pipe Example 1.
# Create named pipe...
mknod trypipe p
# Open named pipe and read message...
cat trypipe &
# Write message...
echo "This is a message!" > trypipe
# Delete pipe...
rm trypipe
To try this example, run the shell script, i-pipex1. This script performs the following actions:
1. The mknod command creates a named pipe called trypipe.
2. The cat command opens trypipe for reading. It blocks because trypipe has not yet been opened for writing. Notice that an ampersand (&) is present at the end of the cat command; this runs the cat command as a background process.
3. The echo command opens trypipe for writing and writes a message. The cat command, blocked until now, resumes execution, and the message appears on the display.
4. The rm command deletes trypipe.