Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <sys/stat.h>
- #include <sys/ioctl.h>
- #include <string.h>
- #include <unistd.h>
- int main (int argc, char* argv[]) {
- char num[2];
- printf("Insert a terminal number to output to [0-n]\n");
- fgets(num, 2, stdin);
- char terminal[10] = "/dev/pts/";
- strcat(terminal, num);
- int fd = open(terminal, O_RDWR);
- char input[1024];
- printf("Enter some text to output to the specified terminal. When done key q to quit.\n");
- // Loop until user enters q and print all text to the specified terminal.
- while (1) {
- if (input[0] == 'q') {
- break;
- }
- fgets(input, 1024, stdin);
- write(fd, input, strlen(input));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement