[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sending a message to the active console



My goodness Dave! What are they teaching you guys at MIT these days!

David Z. Maze wrote:

> Paul Miller <paul@3dillusion.com> writes:
> PM> How can I send a message to the active console?  For example, when
> PM> a cdrom is mounted, mount (or the kernel) reports 'changing media
> PM> type...', etc.  to the active console - if you switch consoles,
> PM> the text will finish on the new active console.
>
> I believe the kernel can do this with the printk() call.
>

Yes, but it only goes to log files/terminals because klogd is running.

> PM> Also, will this type of message appear in xconsole?  If not, how
> PM> can I make it appear in both?
>
> It appears in xconsole, iff the X session is on the currently active
> VC.

Here's the scoop. Note:

chilin$ ls -l /dev/xconsole
prw-r--r--   1 root     root         4083 Jan 22 07:28 /dev/xconsole

/dev/xconsole is a unix "pipe". What is written into it can be read. The
xconsole program simply opens this file for reading and prints whatever
comes through it. You can configure syslog to write stuff to it. Anyone
however may write to it who has appropriate permissions (in my case, only
root). Try this (as root):

echo hello, world > /dev/xconsole

It's as easy as that.

> PM> The reason I'm asking is because I want to make a simple script to
> PM> run in the background and send caller-id messages to the console.
>
> Look at the write(1) and wall(1) utilities; these will let you do this
> without kernel-level hacking.

No need for kernel-level hacking, no need for write or wall. Wanna write to
a VT?

echo hello, world > /dev/tty0

All write does is track down what tty a user is logged in on and writes to
that terminal. If that's the functionality you want you can use that
program, otherwise just write to the terminal device yourself.

--
Jens B. Jorgensen
jjorgens@bdsinc.com



--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: