Linux programming in java
822570Apr 28 2011 — edited May 13 2011Hello all.
I get an interesting taks - a cli programm for UNIX base system. It doesn`t matter what it should do, in this topic important that it should support Linux pipelining, e.g. can perform "ls | less", but of course programm will use it own commands, but support such form of commands. And the language should be Java.
I`m new in Linux and in Linux programming, but try to read as much as possible, so please excuse me if I told smth wrong.:-)
OK, I get this task and start to think it over. First idea was:
1. I get an array of commands from command line in args[].
2. Then just cut string in parts using symbol "|" and parse it one by one.
Idea was not bad, but a man who gie me this task (task is some kind of traning for me), said that I do it in wornd way - unix shell support pipelining for my programm, but programm should be done in specific way.
Ok, I start to read about linux ipc, pipes and linux api. Find some examples in C++, where programm create a child process(using pipe(), fork()) parent and child processes start to send information using pipes. As I understand this is what was meant in words "specific way".
I need an advise of expirenced programmers. How I should programm pipelining? As far as I understand I don`t need to parse all command line and separete it in parts at "|", I just should make I programm that can perform just any possible command in single, and add support of linux pipilining and shell will send commands to my programm by its way without my separating. Am I right? If yes, I still don`t follow what should I add to programm to make shell enable use pipelining?