Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include #include #include #include #include int readLine(int, char *, int); int main(int argc, char *argv[]){ // To execute int status=0, n; // commands
#include#include #include #include #include #include #include int readLine(int, char *, int); int main(int argc, char *argv[]){ // To execute int status=0, n; // commands with no arguments char line[255]; char prompt[30]="Enter your command here> "; while(1){ write(STDIN_FILENO, prompt, 25); n=readLine(STDIN_FILENO, line, 255); if( n Question 4: Compile and test the program below. Then, add what is needed to make it capable to run commands with arguments (A line will contain a command name and its possible arguments). #include #include #include #include #include #include #include int readLine (int, char *, int): int main(int argc, char *argv[]) { // To execute int status=0, n: Il commands with no arguments char line (255): char prompt [30]="Enter your command here>"; while(1) { write (STDIN_FILENO, prompt, 25): n-readLine (STDIN_FILENO, line, 255); if(n + 0) // read a comand break; line (n-1]='\0'; // get rid of and add '\0' 11 for string manipulation if (!fork) execlp (line, line, NULL): wait (&status); if (n=--1) perror ("Reading error"): exit(0); int readLine(int fd, char *buff, int n) { int i=0, m; while(i #include #include <>#include #include #include #include int readLine (int, char *, int): int main(int argc, char *argv[]) { // To execute int status=0, n: Il commands with no arguments char line (255): char prompt [30]="Enter your command here>"; while(1) { write (STDIN_FILENO, prompt, 25): n-readLine (STDIN_FILENO, line, 255); if(n + 0) // read a comand break; line (n-1]='\0'; // get rid of and add '\0' 11 for string manipulation if (!fork) execlp (line, line, NULL): wait (&status); if (n=--1) perror ("Reading error"): exit(0); int readLine(int fd, char *buff, int n) { int i=0, m; while(i <>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started