means that the shell has to wait for the command before to finish before

Means that the shell has to wait for the command

This preview shows page 2 - 5 out of 7 pages.

Image of page 2
2.Separating a command line into a sequence of commandsThis exercise is relevant to Project 1 - A Simple Unix Shell.Continue from C Programming Exercise 3 in Lab 7, modify the program from that exercise so that your program now breaks up a command line into a sequence of commands. Instead of printing out a sequence of tokens from the command line, your program should now print out a sequence of commands and for each command, it prints out a sequence of tokens contained in that command.You may want to consider a new module namedcommand, where the module header defines the following:struct CommandStructure {int first; // index of the first token of the command in the array of tokensint last; // index of the last token of the command in the array of tokenschar* separator; // the command separator that follows the command. It should be // one of the following// "|" - pipe to the next command// "&" - shell does not wait for this command// ";" - shell wait for this command};typedef struct CommandStructure Command; // type name for the command structure// take a list of tokens and break it into an array of commandsint separateCommands(char *tokens[], Command command[]); You may use the following code as the starting point for this exercise: command.h and command.c . Please note this module is not tested at all, so it is guaranteed to have bugs in it. Make sure that you modify the makefile to take into account the module command .
Image of page 3
Unix Programming Exercises
Image of page 4
Image of page 5

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture