-2

the status of the echo bit in the driver for file descriptor 0. Use redirection operator < to attach standard input to other files of devices. Try these experiments:

$ ./echostate < /dev/pts/0 
$ ./echostate < /etc/passwd

Output

enter image description here

plz explain to me the output produced by each of these commands. i don't know these output difference.

echostate.c

#include <stdio.h>
#include <termios.h>
#include <stdlib.h>
main()
{
    struct termios info;
    int rv;
    rv = tcgetattr(0, &info);

    if (rv == -1) {
       perror("tcgetattr");
       exit(1);
    }
    if (info.c_lflag & ECHO)
        printf("echo is on, since its bit is 1\n");  
    else
        printf("echo if OFF, since its bit is 0\n"); 
}
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • 2
    Please also don't add text output as screenshot. Just copy&paste the text and add it to your question. After all it is text, no artwork. – Gerhardh Oct 11 '18 at 10:29

1 Answers1

0

tcgetattr doesn't make sense on a file (/etc/passed), but only on certain types of devices.

That's what the error message is telling you.

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115