Write An IPC Program Using Pipe. Process A Accepts A Character String And Process B Inverses The String. Pipe Is Used To Establish Communication Between A and B Processes Using Python or C++.
============ In File p1.py For Process P1 ============
import os
wfpath="./p1"
rfpath="./p1"
wp=open(wfpath,'w')
wp.write("hello")
wp.close
rp=open(rfpath,'r')
response=rp.read()
print"Reverse of string from process B : %s"%response
============ In File p2.py For Process P2 ============
import os
rfpath="./p1"
wfpath="./p2"
try:
os.mkfifo(wfpath)
os.mkfifo(rfpath)
except OSError:
pass
rp=open(rfpath,'r')
response=rp.read()
print"String recieved from Process A : %s"%response
s=response
s=s[::-1]
print"Reverse is :%s"%s
rp.close()
wp=open(wfpath,'w')
wp.write(s)
wp.close()
rp.close()
============== OUTPUT ============
[hnpandya@localhost ~]$ python processA.py Reverse of string from process B : [hnpandya@localhost ~]$ python processB.py String recieved from Process A : hello Reverse is :olleh
Write An IPC Program Using Pipe. Process A Accepts A Character String And Process B Inverses The String. Pipe Is Used To Establish Communication Between A and B Processes Using Python or C++.
Reviewed by Hardik Pandya
on
1:03:00 PM
Rating:
Thanx its our pleasure to have senior like u..
ReplyDeleteYou're Welcome !! :)
Delete