Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, write your own limited version of the stty system command.

ID: 3936763 • Letter: F

Question

For this assignment, write your own limited version of the stty system command. A man page for the command could look like the following:

NAME
st - change and print terminal line settings
SYNOPSIS
st [SETTING]
DESCRIPTION
Print or change terminal characteristics
-a print the current settings for iuclc, ouclc, echo, and icanon.
Input Settings:
[-]iuclc translate upper case characters to lower case
Output Settings:
[-]ouclc translate lowercase characters to uppercase
Local Settings:
[-]echo echo input characters
[-]icanon enable erase, kill, werase, and rprnt special characters

Some Sample Usages:
st displays synopsis message
st -a displays all the settings in human readable format.
st -echo turns off the echoing of characters
st iuclc turns on translation of upper case characters typed appearing as lower case
You may assume a user will only change one setting at a time.
Hints:
man stty
man tcsetattr
1. understand the problem. 2. plan your solution. 3. implement the solution.
Don't forget to check the C library for any functions that could make your life easier.
The above sample usages are not a complete list. A 10-Point Sample Run [stalica@trig ~]s cc st.c -ost stalicaêtrig ~]5 /st -a -iuclc -olcuc echo icanon [stalica@trig ]s ./st iuclc [stalica@trig ~]s asdfsdfs bash: asdfsdfs: command not found [stalica@trig ]$s ./st -iuclc [stalica@trig ] ASDFSDF bash: ASDFSDF: command not found [stalica@trig ]s ./st -echo [stalica@trig ~Js ./st -echo [stalica@trig ~]S st [SETTING] [stalica@trig ]s -iuclc -olcuc echo icanon [stalica@trig ]S [stalica@trig ]s ./st -a iuclc olcuc echo icanon [stalica@trig js ./st -icanon stalica@trig ]s

Explanation / Answer

#include<stdio.h>
#include<string.h>
#include<unistd.h>
int main(int argc, char ** argv)
{
        if(strcmp(argv[0],"./st")==0 && argc == 1){

                printf("Some sample Usages : ./st displays synopsis message ");
                printf("./st -a displays all the settings in human readable format ");
                printf("./st -echo turns off the echoing of characters ");
                printf("./st -iuclc turns on translation of upper case characters typed appearing as lower case ");
                return 0;
        }
        if(strcmp(argv[1],"-a")==0){

                execlp("/bin/stty","stty", "-a", NULL);
        }
        if(strcmp(argv[1],"-iuclc")==0){

                execlp("/bin/stty","stty", "-iuclc", NULL);
        }
        if(strcmp(argv[1],"-ouclc")==0){

                execlp("/bin/stty","stty", "-ouclc", NULL);
        }
        if(strcmp(argv[1],"-echo")==0){

                execlp("/bin/stty","stty", "-echo", NULL);
        }
        if(strcmp(argv[1],"-icanon")==0){

                execlp("/bin/stty","stty", "-icanon", NULL);
        }
        else{
                printf("-bash :%s command not found ",argv[1]);
                return 0;
        }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote