LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-20-2005, 12:46 PM   #1
stockwatch
LQ Newbie
 
Registered: May 2005
Posts: 3

Rep: Reputation: 0
Question Detecting TTY terminal messages?




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.
 
Old 05-21-2005, 10:10 PM   #2
LostSheepOfThePorn
LQ Newbie
 
Registered: May 2005
Location: Berkeley, CA
Distribution: Linux
Posts: 8

Rep: Reputation: 0
I'm not too sure. Maybe try logwatch(8).
 
Old 05-21-2005, 11:10 PM   #3
sigsegv
Senior Member
 
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
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.
 
Old 05-23-2005, 07:09 AM   #4
stockwatch
LQ Newbie
 
Registered: May 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Logwatch won't do what I need but thanks.

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?

Thanks again.
 
Old 05-23-2005, 07:19 AM   #5
sigsegv
Senior Member
 
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
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.

Last edited by sigsegv; 05-23-2005 at 07:21 AM.
 
Old 05-23-2005, 08:40 PM   #6
stockwatch
LQ Newbie
 
Registered: May 2005
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tty messages to ssshd seasions ? azi Programming 0 05-29-2005 01:14 PM
tty usb terminal? DarkstarNL Linux - Hardware 0 04-21-2004 09:34 AM
Redirecting console boot messages to different tty. cenkozkan Linux - Software 2 01-17-2004 04:11 AM
Blocking TTY terminal text floods ??? khermans Linux - General 1 10-01-2003 07:12 AM
Stop Printer Messages Logging to TTY Cyyb Linux - General 2 06-20-2003 02:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration