Hi,

I ve been given an assigenment in which I have to create a process, open a file and read it by that process, then that process the data to the another process (2nd process) through function pipe (), which capitalizes all the letters. The 2nd process then sends the capitalized data to 3rd process which opens a file for output and print the data in that.
The programming to be done in LINUX and I am a newbie in LINUX programming.

Now I would really appreciate help with opening file for the process. Is it possible at all or not, I dont even know this. So kindly help. Thanks in advance.

I'm sure your instructor has given you much more information than you have given us.

Make sure you review how to open pipes:
man 7 pipe: overview
man 2 pipe: create pipe manual page

And, for good measure, an article on Pipes and filters.


Your professor should have also given you instruction on how to create new processes - whether they be separate programs or simply separate parts of the same program using fork(). (I suspect that your professor has the popen() function in mind -- but I could be wrong.)


Opening and reading a file and writing a new file are both done with the standard fopen() function, as always.

The trick is that your first process will open the file, then write it through the pipe. The second process will read it from the pipe (its own standard input), modify it, and write it to the third process via yet another pipe. The third process opens the target file and writes what it receives from the second pipe (its standard input) to the file.

Hope this helps.

Thanks Duoas.

Yes, my instructor have taught us fork (). Thanks for the links. I hope I will be able to do my assignment now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.