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
plz explain to me the output produced by each of these commands. i don't know these output difference.
#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");
}
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.