Related questions
modify minishell.c to run who, ls, and date with option. who will show the count of users, ls will list files in long listing format and date will show UTC time.
Modify this file so the shell can run commands with options.
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
char *cmd[] = {"who", "ls", "date"};
int i;
while(1){
printf("0=who 1=ls 2=date : ");
scanf( "%d", &i );
if(i<0 || i>2)
continue;
pid_t result= fork();
if(result==0) { /* child */
execlp( cmd[i], cmd[i], (char *)0 );
printf("execlp failed\n");
exit(1);
}
else if (result >0){ /* parent */
int status;
wait(&status);
}
else{
//handle error
}
}
return 0;
}
Step by stepSolved in 2 steps
- Please solve Max in 30-45 minutes with full step and explanation thank u Explain the function of the static folder, templates, route.py file, and run.py file in the Flask frameworkarrow_forwardA student wants to write into a file called myfile, without deleting its existing content. Which one of the following functions should he or she use? f = open('myfile', 'r') f = open('myfile', 'w+b') f = open('myfile', '+') f = open('myfile', 'a')arrow_forwardUSE THE SIMPLE PYTHON CODE PLEASE The username code. The company can choose the specific criteria for the username. The criteria is as follows: a minimum length, a minimum number of capital letters, and a minimum number of special characters. Special charters are [,ドル #, ^, %, . etc]. You will turn in three .py files. The first file called main.py contains your main interface. The second file called functions.py contains all the functions your main code. The third file called parameters.py contains the parameters of the code: the special character list, the minimum length, the minimum number of special characters, the minimum number of capital letters, and the number of tries the user gets to input user name. Your code operates as follows. Display the criteria for the username. Prompt the user to input a username. If the username does not meet criteria, tell the user why and re prompt to enter in a username. Repeat until you reach the maximum number of tries allowed.arrow_forward
- Which parameter describes the destination directory which would contain the archive? a) -archiveName <name> b) <source> c) <destination> d) none of the mentionedarrow_forwardHow do I create a Python program where get request to / should return index.html, get request to /yourname should return the personal file and post request to /comment should prase the data from the post request body and send the text data back to the client?arrow_forwardThe given text files represent a list of account numbers and associated balances. Balances change over time. If a balance is later in the file, then this implies the balance for that customer is more recent. Ask the user for a file name then display the most recent balance along with the high and low balance. balances-0.txt customer id balance1 93ドル.831 805ドル.242 866ドル.454 943ドル.283 764ドル.121 798ドル.004 395ドル.595 644ドル.264 18ドル.314 814ドル.97arrow_forward
- Suppose a csv file contains three comma-separated values (strings) on each line (see the leftcolumn of the example table below). Assume, each line of values are, respectively, thewidth, height, and depth of a box. Write a program called box.py and add thefollowing functions to this program.• read_file() takes a csv filename as a parameter that contains the widths, heights, anddepths of all boxes. This function must read the content of the file, store these values ina 2-D list as shown in the right column of the example table below, and return this list.All strings must be converted to integers before they are stored in the list. Example:csv data 2-D list[[15, 6, 3],[3, 7, 4],[6, 9, 3],[15, 6, 11],[6, 5, 5],[13, 10, 9],[9, 10, 3],[14, 5, 4],[4, 6, 11],[12, 10, 9]]• Add another function called max_volume() to this program that takes this 2-D list as aninput parameter. Each item in that list contains 3 integers representing the dimensions ofa box (i.e., width, height, depth). This...arrow_forwardI need the script to create a txt file thats made up of all the individual entries as well as the individual txt files for each entry. The script pasted below prints individual entries but I need it to print 1 additional txt file thats like a sum of all the other created txt files. Thank you! //script: #include <stdio.h>#include <stdlib.h>#include <string.h> #define MAX_NAME_LENGTH 50#define MAX_WARRIORS 7//Usagi Tsukino 1.98//Rei Hino 3.2//Amy Mizuno 4.0//Makoto Kino 2.9//Minako Aino 2.21//Haruka Tenou 3.5//Michiru Kaiou 3.78 struct SailorWarrior { char name[MAX_NAME_LENGTH]; char name2[MAX_NAME_LENGTH]; float gpa;}; int main() { struct SailorWarrior warriors[MAX_WARRIORS]; char filename[MAX_NAME_LENGTH + 5]; // +5 for ".txt0円" int i; for (i = 0; i < MAX_WARRIORS; i++) { printf("Enter the name and GPA for Sailor Warrior #%d: ", i+1); scanf("%s %s %f", warriors[i].name,warriors[i].name2, &warriors[i].gpa);...arrow_forwardVB.net What is the syntax to create a new file using streamwriter without structure or arrays?arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY