LINUX shell Project


I have been given this project by my OS doctor I have no experience with LINUX nor UNIX and I do not know where to start

Create a new file shell.c (or shell.cpp if you prefer C++). This will be our main shell program that will execute commands from a command line. Our shell should intepret the following built-in commands:
 cd: changes the current working directory
 pwd: prints the current working directory
 echo: prints a message and the values of environment variables
 exit: terminates the shell
 env: prints the current values of the environment variables
 setenv: sets an environment variable

To implement the first task we will need to write a "parser" program that parse a line and tokenize it into separate words. This program includes a routine tokenize to split up a command line into an array of strings (tokens), We need this array to match and interpret the command (first array element) and its arguments (the rest of the array). You can do a simple search on "parsers.c" or "parser.cpp" on the internet and you will find some to use or help you writing you own parser.
Add the main routine, the tokenize, and interpret functions to your shell.c program. The intepret function must be extended to implement the built-in commands.

Can anyone help with this, please?
This has nothing to do with Linux or Unix as such. A command prompt is a command prompt. How to execute an external command might be OS-specific though.

This looks like homework.

while( std::getline( std::cin, line ) ) {
  if ( "exit" == line ) return 0;
  else ...
return 0;

There you have a shell that understands one built-in command, "exit". I leave the line 3 for you to flesh out.
Topic archived. No new replies allowed.