[SOLVED] how do i stuff a keystroke into another virtual terminal's stdin?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What is the application or program that you're trying to "stuff a p" into? Can it be told to listen to a pipe for commands? If so, send the keystroke or message through the pipe into the program. Look up the `mkfifo` command for info on this.
Also look up the `write` command. There's another command too for sending messages to other tty's but I think they're intended for sending messages to humans using the terminals, not to programs running in the terminals.
Anyhow, if the pipe idea is no good or you still want more info, maybe tell us a bit more about the situation and requirements, i.e. the program(s) involved and desired functionality you're trying to accomplish, etc. More detail might give someone an idea.
Oooo, looks cool. I just stumbled across this thread, and sounds interesting. Once I get home from work, I am going to try this out, and possibly extend the code a bit and have fun with it. If I do, I will gladly post what I have come up with =D
And other consoles works? Usually on the console tty7 is runnig xserver, this program will not work with such code. Also the program can work without connected console. For me, I must be root, to execute ioctl function, you may suid to root your program, but this is some insecure solution.
Anyway you can move this thread to Programming forum. Those people should give you better answers.
A simple solution for what you what to do is a bad idea security wise, so the system probably won't allow it. You probably need to learn some form of IPC like corba or sending messages on dbus.
Making the owner root and setting the sticky bit works. It's a personal system so I don't mind. It would be nice to limit its effectiveness to processes owned by the caller.
This is only sample. You need add to this code error checking routines, etc. You must run it as root to work, due ioctl function (maybe there are other methods).
The code doesn't work for me either. I don't get any error message or such, but when I try to do the terminal injection, nothing happens at all.
It works for me if I run it as root. I made root the owner and set the sticky bit so anyone can use it. This is a huge security hole but I'm the only user of my computer. I added reading input for a string to pass and a target terminal and report the outcome of the calls. It works as non-root to the terminal in which I run it. Tell us what your error is.
Sorry for digging this up, but I did not even realize that you replied back man. My bad... I will post what happens tonight once I get home from work. I know for sure though that it was something to do with a ioctl function or error....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.