/* writevt.c - put text in tty */ #include #include #include int main(int argc, char **argv) { int fd; char *vterm = argv[1]; char *text = argv[2]; if( (fd = open(vterm, O_RDONLY)) < 0) { fprintf(stderr, "Could not open tty\n"); return 1; } while(*text) { if(ioctl(fd, TIOCSTI, text++)) { fprintf(stderr, "TIOCSTI ioctl failed (try with sudo)\n"); return 1; } } return 0; }