1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vikki [24]
3 years ago
7

The program allows the user to type in any linux command and then executes that command, such as "pwd" or "echo". The problem is

that it should allow multiple commands to be typed in and executed at the same time, but it only allows one at a time currently. Please help fix it so it allows multiple commands to be typed and executed.
Code:
#include
#include
#include
#include
#include
#include
void parse(char *line, char **argv)
{
while (*line != '\0') { /* if not the end of line ....... */
while (*line == ' ' || *line == '\t' || *line == '\n')
*line++ = '\0'; /* replace white spaces with 0 */
*argv++ = line; /* save the argument position */
while (*line != '\0' && *line != ' ' &&
*line != '\t' && *line != '\n')
line++; /* skip the argument until ... */
}
*argv = '\0'; /* mark the end of argument list */
}
void execute(char **argv)
{
pid_t pid;
int status;
if ((pid = fork()) < 0) { /* fork a child process */
printf("*** ERROR: forking child process failed\n");
exit(1);
}
else if (pid == 0) { /* for the child process: */
if (execvp(*argv, argv) < 0) { /* execute the command */
printf("*** ERROR: exec failed\n");
exit(1);
}
}
else { /* for the parent: */
while (wait(&status) != pid) /* wait for completion */
;
}
}
void main(void)
{
char line[1024]; /* the input line */
char *argv[64]; /* the command line argument */
while (1) { /* repeat until done .... */
printf("Enter Shell Command -> "); /* display a prompt */
fgets(line, 1024, stdin); /* read in the command line */
printf("\n");
parse(line, argv); /* parse the line */
if (strcmp(argv[0], "exit") == 0) /* is it an "exit"? */
exit(0); /* exit if it is */
execute(argv); /* otherwise, execute the command */
}
}
This function receives a commend line argument list with the */ /* the first argument being cd and the next argument being the */ /* directory to change.
Computers and Technology
1 answer:
asambeis [7]3 years ago
6 0
Where is the question
You might be interested in
What do you think has happened to the Earth? Provide evidence from the movie. *
Jet001 [13]

Answer:

We dont have the movie-

Explanation:

Maybe just look at ur notes

8 0
3 years ago
Write a program using for loop to find the cube of numbers from 50-100 <br> FASTT
Gelneren [198K]

Answer:

JAVA

for(int i = 50;  i <= 100          i++;)

{

   int cubedNum = Math.pow(i, 4);

   System.out.println(cubedNum);

}

Explanation:

The For loop is set so that it will go the amount of times until the variable i reaches 100, then it will stop increasing i.

Then, we raise i to the 4th power in the loop, and then print it out.

<u><em>#teamtrees #PAW (Plant And Water)</em></u>

8 0
3 years ago
A method which applies to the class in which it is declared as a whole and not in response to method calls on a specific object
Mandarinka [93]

Answer:

D) Static method

Explanation:

A static method is a method that is created only for the class and not it's instance variables or objects. Such methods can only be accessed by calling them through the class's name because they are not available to any class instance. A static method is created by prefixing the method's name with the keyword static.

A static method cannot be overridden or changed. You create a static method for a block of code that is not dependent on instance creation and that can easily be shared by all instances or objects.

5 0
3 years ago
Components of an operating system include process, memory, and file management. What is another component of an operating system
Ksivusya [100]
Those are all the components of an operating system

8 0
3 years ago
Read 2 more answers
Addressing is an added feature on the Internet, and is not required for proper operation of the Internet, as packet switching is
Irina18 [472]

Answer:

True

Explanation:

The statement is true. Packet switching is a method that groups the data and transmit it over the digital network. It is basis for communication in the computer. When the two host decides to communicate the network creates a control function and data is transmitted. Addressing is an added and is not mandatory for the operations of the internet as packet switching.

7 0
3 years ago
Other questions:
  • Gary lives in an area that receives high rainfall throughout the year. Which device would be useful to him to maintain his compu
    10·2 answers
  • The main file type used when saving a powerpoint presentation is the?
    10·1 answer
  • Write a sentence about a mineral you use and how you use it
    12·1 answer
  • Design and code a program including the following classes, as well as a client class to test all the methods coded:A Passenger c
    7·1 answer
  • The best way to ensure the accuracy and safety of your accounts is to:
    10·1 answer
  • Mencione algunos ejemplos en donde sean utilizadas las máquinas de aire comprimido. Justifique su respuesta.
    7·1 answer
  • At one time, a station sign-off test pattern was designed so TV owners could adjust the quality of their picture and sound
    9·1 answer
  • Consider the following class, which models a bank account. The deposit method is intended to update the account balance by a giv
    8·1 answer
  • What is your robloz?​
    12·1 answer
  • 1.1 give five (5) reasons why modeling is an important part of system analysis and design
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!