Create a shell in C language 1) Create an argument tokenizer then write a main() function that...

60.1K

Verified Solution

Question

Programming

Create a shell in C language

1) Create an argument tokenizer then write a main() functionthat prints a prompt inputed by user, accepts input, and tokenizesthe input.

2) Use the argument vector to an executeCmd() function with intexecuteCmd(char **args);

3) The function should return a -1 if an error, or a zerootherwise. Inputing an “x” in the prompter will exit theprogram.

4) Write an executeCmd() function that can execute any programin the background and redirect the output of any program to a file.Any number of functions can be executed in executeCmd() such aslisting the files in the current directory, listing files in longformat or displaying current working directory (ls, ls -a,pwd).

5) The program should run in the background working on thefunction, but the prompt should be available to take new requests($ cat prog.c &).

6) Function execBackground() should be used to determine when ajob should run in the background. The function will strip the‘&’ character from the argument vector. This function will alsolet the output of a running program to be redirected to a file ($grep if prog.c > foo).

7) The maker should include two source files and one header fileas well as a makefile. The main() function, the executeCmd()function and all supporting functions will be in a fileprogram_exec.c and the function prototype for executeCmd()program_exec.h.

Answer & Explanation Solved by verified expert
3.6 Ratings (296 Votes)
includeincludeincludeincludeincludedefine GNUSOURCEint executeCmdchar    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students