Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple example of TWO-WAY pipe

ksh Inter-process comm's

Simple example of TWO-WAY pipe

by  mi294r3  Posted    (Edited  )
This is an very simple example of a ksh script that starts
a child process with a two way pipe.


The Parent process displays its process ID [color green]$$[/color]

starts the child process with a two-way pipe [color green]|&[/color]

displays the process ID of the child [color green]$![/color]

reads from the two-way pipe [color green]read -p[/color]
and asigns what it read to CHILD_MSG

[color red]------------------------[/color]

child process just echo's its own process ID [color green]$$[/color]
for the child process stdin and stdout a forced to the pipe.

[color red]------------------------[/color]

parent process displays value of CHILD_MSG which was read from pipe

[color red]------------------------[/color]
parent script
[color red]------------------------[/color]
[color green]#!/bin/ksh
echo "My Process ID is $$"
child |&
echo "The childs process ID is $!"
read -p CHILD_MSG
echo "The child states his process ID is ${CHILD_MSG}"[/color]
[color red]------------------------[/color]
child script
[color red]------------------------[/color]
[color green]#!/bin/ksh
echo $$ [/color]

JRjr [morning]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top