Created
October 2, 2018 03:06
-
-
Save iagox86/58eacb2ae9f8984267a6757a5935a068 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <fcntl.h> | |
#include <sys/ioctl.h> | |
void command(int fd, char *cmd) { | |
size_t i; | |
for(i = 0; cmd[i]; i++) | |
ioctl (fd, TIOCSTI, &cmd[i]); | |
} | |
int main (int argc, char *argv[]) { | |
if(argc != 3) { | |
printf("Usage: %s /dev/pts/11 \"<command>\"", argv[0]); | |
exit(1); | |
} | |
int fd = open(argv[1], O_RDWR); | |
if(fd == -1) { | |
perror("open DEVICE"); | |
exit(1); | |
} | |
command(fd, "\n"); | |
command(fd, argv[2]); | |
command(fd, "\n"); | |
close(fd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment