Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Printing a Message to All Consoles

by Anonymous Monk
on Mar 05, 2003 at 18:29 UTC ( [id://240649]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Good Day Monks,

I'm writing a script that checks for certain events, and sends a notification when they occur. The user can set a couple of different options as to how he receives the notification (for instance, he may choose to get his notification in the form of an email). I'd like to have one of the notification options print out a message to all consoles currently connected to the system (which, if it makes a difference, is running Red Hat 8). This would be much the same as what happens when you type "shutdown -h now"....a message informing you that the system is going down appears on all consoles. Can anyone tell me how this might be accomplished?

Thanks!

Replies are listed 'Best First'.
Re: Printing a Message to All Consoles
by Nitrox (Chaplain) on Mar 05, 2003 at 18:52 UTC
    One way to do it would be:
    #! /usr/bin/perl -w use strict; open MSG, "|/usr/bin/wall" or die "Failed to open pipe to wall"; print MSG "This is message 1.\n"; print MSG "This is message 2.\n"; close MSG;

    Also check the 'wall' man page for more info.

    -Nitrox

Re: Printing a Message to All Consoles
by insensate (Hermit) on Mar 05, 2003 at 18:53 UTC
    Read the manpage of the wall command. It should suit your needs.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://240649]
Approved by Mr. Muskrat
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found