Hello fellow programmers,
I was recently given a task of creating a CLI in c under a unix based system. I have almost completed the task, but am currently stuck with 2 particular points, the logic of the task is as follows (direct reference to documentation):
get input line
if end of input exit
break line into words
found := false
if command is builtin
found := true
found := find_and_execute( line)
if not found report error
The marking of the task is as follows:
1. Read a full line of text from the user
2. Detect exit as first word
3. break line into words
4. Appropriate test of fork() return value
5. Correct process handles new task
6. Appropriate choice of exec() family member
7.Correct usage of exec() member
8. Correct use of wait()
9. Printing the exit status
10. Working cd implementation
I have completed points 1,2,3,4,6,8,9 and attempting point 10 currently.
I request assistance in undertaking points 5 and 7. I have identified that i would use the execv family member, but not am aware of how to use it in this situation.
The code of the execv family member should be located within the child process and if a keyword is entered that is identifed by unix (eg. ls = list directory), the process should carry out the task( ls = display output of list directory).
I am allowed to receive assistance, as long as reference is made regarding who i obtained assistance from. Unfortunatley as this is a current task i am reluctant to post up any code and am therefore requesting trust and reliance in the c programming community.
Please advise me in how i may be able to provide the code, without making it public, would people be willing to provide email addresses to which i can send the code?
Please also note that the program will only compile on a unix machine.