Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(1) Write a program that uses popen() to do the following: The program recursively find all the .c files under the current directory (you have

(1) Write a program that uses popen() to do the following:

The program recursively find all the ".c" files under the current directory (you have to search all the subdirectories also). Then display all file names in UPCASE letters.

Requirements:

(a) Create two pipes, using popen() for each one.

(b) You need to use popen to run "find" command to find names of c files.

(c) You need to use popen again to run "tr a-z A-Z" command to convert lower case input to upcase output.

(d) use find to find files. Check the following:

https://kb.iu.edu/d/admm

(e) If you want to find more about the "tr" command, do some googling or check the following link:

https://www.linuxnix.com/16-tr-command-examples-in-linux-unix/

(2) Create a server program and a client program. The client program reads a line from a text file, converts everything to upper case letters, and send it to the server, using a named pipe. It pauses for 1 second, and repeats the above process, until the end of file.

The client sends a "Stop" string at the end.

The server displays any thing it receives. The server quits when it sees "Stop". The server needs to cleanup by deleting the named pipe.

Your programs (client and server) need to create the name pipe first, if it does not exist.

(3) Re-implement Q3, using SysV shared memory.

Here the difficult is that the client needs to find a way to let the server knows that its have written something to the shared buffer. You cannot just modify the buffer and hope the server will find out --- what will happen if the new line of text is identical to the contents already in the buffer? (I want you to test this by addling two identical lines in the testing file)

In the examples I showed you in the class, I used sleep(), but clearly it is not an elegant way to things and it may fail.

I suggest you reserve an area in the shared memory section (or create a new shared memory section) to hold an integer. Each time AFTER the client updates the text buffer, its increments this value. Server will notice the change.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions