Shell Assignment : Creating a CLI please help!
Hi guys,
I'm new to this forum and i've got an assignment to complete and would much appreciate any help on this matter.Let me post you the question:
Implement a command line interface which will execute all UNIX commands and save intermediate values of pipe (|) and redirection operation (>>) commands with the help of files related system calls and dup2. The program should work as follows
The program should provide a command interface with following features.
It should support internal commands like Start, End, LogComm, LogInt, UnLogComm, and UnLogInt. These commands are just to enable / disable various functionalities of the interface. They are not a part of UNIX system. The functionalities of these commands are as follows
Start -> start the functioning of your own interface
End -> Exit from your interface
LogComm -> Log all the commands executing in the command interface with status as success/failure.
LogInt -> Logs intermediate values of pipe or redirection commands in standard format specified
UnLogInt -> stop logging intermediate values of pipe and redirection commands
UnLogComm -> Stop logging commands executed in the interface.
The new command interface should support all the commands in UNIX system and should save the intermediate value of pipe and redirection commands into a file with the following format
ls –l | wc | wc
The intermediate output file (name of the file should be InterLog.txt) should print the output as follows
ls –l output is
[ls –l] drwxrwxrwx …………………………
[ls –l] –rwxr—r-- ……………………………
****************************************
ls –l | wc output is
[ls –l | wc]
****************************************
ls –l | wc | wc output is
[ls –l | wc | wc]
****************************************
If the LogComm is on then the system should create a file named CommLog.txt which will store information about all the commands executed in the system as follows
ls –l Success
ls –l | wc Success
ls –l | wc | wc Success
ls Success
ls >> a1.txt Success
The command interface should work as follows for redirection.
ls >> a1.txt
The intermediate file will store ls output alone. Where as a1.txt will contain information what it had earlier and the output of ls.
********************************************************
Well, that's it...I'm new to shell programming and have background in basic C data structures....Any help in coding will be much appreciated...
Thanking You,
Vikram
|