Question: 4. (Part A 20 points, and Part B 10 points) Write program os service that prints and executes all command-line arguments passed to main(). Command-line

 4. (Part A 20 points, and Part B 10 points) Write

4. (Part A 20 points, and Part B 10 points) Write program os service that prints and executes all command-line arguments passed to main(). Command-line arguments are accessible via the argc and argv[] parameters; ignore envp[]. Part A, 20 points, command line arguments. Write and execute program os service by providing the 3 command line arguments pwd Is whoemi; interpret and execute each of the 3 command line arguments as a valid Unix/Linux command.Execute them via the runtime provided system() function. Show all sources and resulting output. A plausible command to execute could be, including the actual a.out command, could be: ./a.out pwd Is whoami Your generated output must be very similar to the one below: argc = 4 argv[1] = pwd Executing command 'pwd' /Users/herbertmayer argv[2] = ls Executing command 'ls' Applications Downloads Music hw1.c argv[3] = whoami Executing command 'whoami' herbertmayer Part B, 10 points, system() function: Execute the second part of os service during the same run. Use the built-in function system() three times. Provide three Linux commands you plan for system() to execute. These must be: system( "Is" ), system( "pwd" ), CSC 139 OPERATING SYSTEMS SAC STATE | HW 2 and then system( "Ils; cd mine; Is; cd ..; Is" ). Assume there be a directory named "mine". A sample, plausible output is shown below: here be a director OAC STATE next call: 'system(1s)'. Applications Downloads Music hw1.c next call: 'system(pwd)'. /Users/herbertmayer next call: 'system(ls; cd mine; ls; cd..; ls)'. Applications Downloads Music hw1.c Birthdays homes my_files_11_2019 ... Applications Downloads Music hw1.c 4. (Part A 20 points, and Part B 10 points) Write program os service that prints and executes all command-line arguments passed to main(). Command-line arguments are accessible via the argc and argv[] parameters; ignore envp[]. Part A, 20 points, command line arguments. Write and execute program os service by providing the 3 command line arguments pwd Is whoemi; interpret and execute each of the 3 command line arguments as a valid Unix/Linux command.Execute them via the runtime provided system() function. Show all sources and resulting output. A plausible command to execute could be, including the actual a.out command, could be: ./a.out pwd Is whoami Your generated output must be very similar to the one below: argc = 4 argv[1] = pwd Executing command 'pwd' /Users/herbertmayer argv[2] = ls Executing command 'ls' Applications Downloads Music hw1.c argv[3] = whoami Executing command 'whoami' herbertmayer Part B, 10 points, system() function: Execute the second part of os service during the same run. Use the built-in function system() three times. Provide three Linux commands you plan for system() to execute. These must be: system( "Is" ), system( "pwd" ), CSC 139 OPERATING SYSTEMS SAC STATE | HW 2 and then system( "Ils; cd mine; Is; cd ..; Is" ). Assume there be a directory named "mine". A sample, plausible output is shown below: here be a director OAC STATE next call: 'system(1s)'. Applications Downloads Music hw1.c next call: 'system(pwd)'. /Users/herbertmayer next call: 'system(ls; cd mine; ls; cd..; ls)'. Applications Downloads Music hw1.c Birthdays homes my_files_11_2019 ... Applications Downloads Music hw1.c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!