Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program ( myshell 1 . c ) to do the following task in a loop ( 1 ) get a command from standard

Write a program (myshell1.c) to do the following task in a loop
(1) get a command from standard input, into a variable
(2) if the command is "exit"
then exit the program (to be terminated)
else if the command is "listall"
then you replace the input by "Is -la"
else if the command is "showme"
then replace the command by "w | grep xyz" where xyz is the first 3 characters of your netid
for example, w | grep rkm (for netid=rkm010300)
else run the command via system call
call a system call to run the input command, e.g., system("Is -l");
(3) repeat the loop (that is, back to step (1)).
compile the program (and its executable name is: myshell1) and run the program with the following input commands
date ; hostname ; uname -a
Is -I
Is ->> mydir.txt
Is -I $HOME > myhome.txt
who | grep 'whoami'
w > myuser.txt ; w | grep 'whoami'
listall
showme
Is -I myshell1.c
head myshell1.c
exit
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions