Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
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.
I've trawled this site and the net in general for a few days looking for a possible solution and have come up with nothing. I hope someone can point me in the direction of a solution.
I am trying to automate some tasks which involve reading tty terminal messages. I have a process running and on certain events it will fire a message to the terminal. Is there some way to detect what messages are being sent to the terminal. For example when in a terminal as su and the root user has mail a message will appear indicating the fact that unread mail is present. Is there and generic way of determining these messages - possibly a log that reports them?
I'm trying to automate many tasks with Perl but this is holding everything back. I need to be able to know the contents of the message without having to be sitting in front of the terminal.
I'm not that hot with Linux less than a years experience, so this may be an unreasonable request but thanks in advance for any help received.
Last edited by stockwatch; 05-20-2005 at 12:48 PM.
Without more detail on what exactly it is you're hoping to accomplish I'm just taking a stab in the dark here, but there's almost certainly a better way to do what you want.
If there is an easier way to do what I hope to do then I'm all for it. As far as I'm aware what the process is doing is sending a message direct to the device in this case the terminal that called the process. I've done some research and discovered that a way of trapping these messages is to create a pseudo tty using /dev/ptmx and /dev/pts/ and divert STDIN, SDTOUT and STDERR to the pseudo tty thereby capturing the messages
This is pretty lowlevel and while I think I understand whats being done, my ability to actually implement this is extremely questionable.
I've also had a look at expect. Does anyone know if this can possibly achieve the results I'm looking for?
You mention perl in your first post ... have you considered popen() or IPC?
You could also redirect the output of the program you're trying to interact with to a file, or pipe it to your script, or use a fifo, or ... you get the idea.
Thanks, I appreciate the help. I can't interact with the program directly. It is a running daemon which produces no output directly. It does not send any messages to STDIN, STDERR, or STDOUT. It somehow sends a message to the device directly which is the terminal with scope. Going back to the mail alert as it is the clearest example I can give. When a message is received by a user a message is displayed in the terminal indicating that new mail is present in /var/spool/mail/user or wherever. This message does not appear in the terminal as STDOUT or STDERR and can't be piped to a file. It isn't a case of running a process, waiting for some output and then terminating. Whenever new mail arrives to the user at localhost an alert appears in the terminal. What I want to do is somehow detect this alert as it appears in the terminal.
My previous post about the pseudo tty was inaccurate on reading back. The pseudo tty method would force all terminal messages to the pseudo tty which could then be piped to a file and filtered/searched for the required data. From what I have discovered it requires some pretty low level C to achieve this and that is far beyond my current skillset.
Thanks for taking the time to look at my questions. Like I said my linux experience isn't far-ranging so I may be asking the right things the wrong way and causing confusion.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.