4. Extended CLI: Extend the CLI example discussed in class (slide 64 in Ch_03_a.
ID: 3601596 • Letter: 4
Question
4. Extended CLI: Extend the CLI example discussed in class (slide 64 in Ch_03_a.pdf) so it is not limited to only the list of possible commands. The new program should loop through the following:
1. Prompt to the user and wait for their input.
2. Read the user input, tokenize it and build a NULL-terminated string array.
3. Create a new process to execute the user command
4. Parent process should wait until user command is executed before it returns to step 1
Here is the CLI code in C:
main() {
char *cmd[]={“who” , “ls” , “date”};
int i;
while(1){
printf(“0=who, 1=ls, 2=date :) ;
scanf(“%d”, &i);
if (fork() == 0) {
execlp(cmd[i], cmd[i],0);
printf(“command not found ”);
/*exec failed*/
exit(1);
} //if
else
wait(0);
} //while
} //main
Explanation / Answer
“Kindergarten Cop”, and "Along came Polly". I knew then I had to have a ferret. A few
years went by before I thought about getting a ferret. That is until I saw them
again in the pet store. I saved my money and finally got one. She was six weeks old,
tiny and adorable. I loved her instantly. I had not done much research until after I
got her.
</div>
<div class="ferrets-playing-images"></div>
<div class="standard-paragraph">
As I mentioned before I got my first ferret, I did a lot of research. Using the internet
was barely an option in the early 90s. So, I used other resources. If you are interested
in getting a ferret there are a few facts you need to research and some fun facts you will
enjoy reading about. Let's start with the facts that you will need to know.
</div>
<div class= "ferret">
<div class= "Diet">
<div class= "name">Diet</div>
<div class= "type">Should be Protein Based foods.</div>
</div>
<div class= "Health">
<div class= "name">Health</div>
<div class= "supplies">Bathing, Suppliments, nail clipping, ear cleaner, illness remedies, etc.</div>
</div>
<div class= "Living supplies">
<div class= "name">Housing Supplies</div>
<div class= "supplies"> Cage, litter box, litter, sleeping area, food and water dish.</div>
</div>
</div>
<div class="standard-paragraph">
Over the years I have owned 3 ferrets and each one has been more lovable and entertaining
than the last. The one I currently own is now 5, almost 6, years old and very energetic.
Now that I am getting older I do not have a lot of time to train a new ferret but there are
older ferrets that still need a home and those are the ones I try to gear myself towards.
</div>
<div class="standard-paragraph">
Ferrets are known to suffer from several distinct health problems. Among the most common are cancers affecting the adrenal glands, pancreas, and lymphatic system. Viral diseases include canine distemper and influenza. Health problems can
occur in unspayed females when not being used for breeding. Certain health problems have also been linked to ferrets being neutered before reaching sexual maturity. Certain colors of ferret may also carry a genetic defect known as
Waardenburg syndrome. Similar to domestic cats, ferrets can also suffer from hairballs and dental problems.
</div>
<div class="standard-paragraph">
Many ferret owners in England and Europe keep their ferrets outdoors, but that practice is rare in the United States. This is because heartworm disease,
canine distemper, and rabies are common diseases in the U.S., and ferrets can develop all of these. Another reason why ferrets do better inside is because they are extremely prone to heatstroke, and any temperature above 75°F can be dangerous.
Ferrets are safest and most comfortable at 65°-68°F. It is very important that a ferret has a safe and secure cage, like the Ferret Nation. For a single ferret, the smallest cage you put him in should be no less than 3 ft long by 2 ft high.
Obviously, a bigger cage is better. If you have multiple ferrets, you will need a multi-level cage.
</div>
<div class="standard-paragraph">
Ferrets are very intelligent and highly curious, which can lead to some frustrating moments for unprepared ferret owners! They require training and
lots of interaction with humans for proper socialization. Ferrets are social animals that bond with their owners and their fellow ferret cage mates
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.