Question

In: Computer Science

Using Virtualbox in Debian, write a simple program (a single .cpp file) in Linux shell C++...

Using Virtualbox in Debian, write a simple program (a single .cpp file) in Linux shell C++

Rules:

-Use fork(), exec(), wait(), and exit()

_______________________________________________________________________________________________________________________________________________

-A line of input represents a token group.

-Each token group will result in the shell forking a new process and then executing the process.

e.g. cat –n myfile.txt // a token group

-Every token group must begin with a word that is called the command(see example above). The words immediately following a command are calledarguments(e.g. there are two arguments for the catcommand above).A command may be followed bynone, one, or more argumentsas the command allows to have.

_______________________________________________________________________________________________________________________________________________

Shell Commands:

ls: a token group containing one token(i.e.a command)

ls -l: a token group containing two tokens (i.e.a command and an argument)

sort infile: a tokengroup containingtwo tokens (i.e.acommand and an argument)

dir: a token group containingonly one token (i.e.a command)

sort –dinfile: atoken group containingthree tokens (i.e.a command and two arguments)

cat infile: a token group containing two tokens (i.e.a command and an argument)

Lines of input are interpreted once their tokens are correctly extracted.Your shell should first print a # sign to the screen representing a prompt and wait there until the user types in a command. Your shell then spawns a child process to carry out the command.When yourshell finishes processingthe current line, it prints a # sign again to the screen waiting for the user to type in another command.This process is repeated until the user presses Ctrl-C to terminate your shell.

-Every command is to be interpreted as a valid Linux executable to be executed.

-All commands are assumed to be in the current directory.

-After interpreting a command, the shell should wait for the forked processto terminate before processingthe next line of input.

The program should be able to extract tokens from each input line entered by the user. If you have problems with extracting tokens from input lines, you may use the C++ library function strtok() to do it.

Solutions

Expert Solution


Related Solutions

Using Virtualbox in Debian, write a simple program (a single .cpp file) in Linux shell C++...
Using Virtualbox in Debian, write a simple program (a single .cpp file) in Linux shell C++ Rules: -Use fork(), exec(), wait(), and exit() _______________________________________________________________________________________________________________________________________________ -A line of input represents a token group. -Each token group will result in the shell forking a new process and then executing the process. e.g. cat –n myfile.txt // a token group -Every token group must begin with a word that is called the command(see example above). The words immediately following a command are calledarguments(e.g....
This program is a simple version of the linux shell using execvp by forking using C...
This program is a simple version of the linux shell using execvp by forking using C Currently this program of the shell assumes user enters no spaces before and no extra spaces between strings. Using exec, an executable binary file (eg: a.out) can be converted into a process. An example of using exec is implementing a shell program or a command interpreter. A shell program takes user commands and executes them. int execvp(const char *file, char *const argv[]); Same as...
Using C Write a program that will serve as a simple shell. This shell will execute...
Using C Write a program that will serve as a simple shell. This shell will execute an infinite for loop. In each iteration of the loop, the user will be presented with a prompt. When the user enters a command, the shell will tokenize the command, create a child process to execute it and wait for the child process to be over. If the user enters an invalid command, the shell should recognize the situation and show a meaningful message....
Write a C++ program based on the cpp file below ++++++++++++++++++++++++++++++++++++ #include using namespace std; //...
Write a C++ program based on the cpp file below ++++++++++++++++++++++++++++++++++++ #include using namespace std; // PLEASE PUT YOUR FUNCTIONS BELOW THIS LINE // END OF FUNCTIONS void printArray(int array[], int count) {    cout << endl << "--------------------" << endl;    for(int i=1; i<=count; i++)    {        if(i % 3 == 0)        cout << " " << array[i-1] << endl;        else        cout << " " << array[i-1];    }    cout...
write a c# program that: The file is using a very simple form of compression in...
write a c# program that: The file is using a very simple form of compression in which there are no spaces, each word is separated by camel casing. For Example, the string "TheCatWillRun" is parsed as "The Cat Will Run". *Now for the statistics* Prints to the console the following statistics about the content in the file retrieved above. - How many of each letter are in the file - How many letters are capitalized in the file - The...
Using pthread_create(), pthread_join(), and pthread_exit(), write a C or C++ program running on VirtualBox Debian VM...
Using pthread_create(), pthread_join(), and pthread_exit(), write a C or C++ program running on VirtualBox Debian VM shell to sort a list of signed integers in nondecreasing order using the sorting algorithm of your own choice from a text file containing the integers. The input data should be stored in a file named p2data.txt Sort a list of signed integers in nondecreasing order using three threads, among which two of them are sorting threads responsible for sorting each of the two...
Write a shell program named HELLO2(this should be done in linux, using bash) Consider files in...
Write a shell program named HELLO2(this should be done in linux, using bash) Consider files in the current directory whose names end in 't' or 'z'. For such files only, your program should list certain LINES of the file(s). These lines are those that have at least 4 x's somewhere in the line. Note that the x's may be upper- or lower-case, and may be separated by other characters; so the following 3 lines DO match: XXxX and more things...
please write in c using linux or unix Write a program that will simulate non -...
please write in c using linux or unix Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
Please write in C using linux or unix. Write a program that will simulate non -...
Please write in C using linux or unix. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
Using OOP, write a C++ program that will read in a file of names. The file...
Using OOP, write a C++ program that will read in a file of names. The file is called Names.txt and should be located in the current directory of your program. Read in and store the names into an array of 30 names. Sort the array using the selection sort or the bubblesort code found in your textbook. List the roster of students in ascending alphabetical order. Projects using global variables or not using a class and object will result in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT