Operating System - HP-UX
1826631 Members
3349 Online
109695 Solutions
New Discussion

Re: Unix mail solution where message breaks on screen

 
David Fosgate_1
Occasional Advisor

Unix mail solution where message breaks on screen

Looking for a way to get messaging to break on the screen for our system operators. I'm developing a number of monitoring scripts that will create email to our operations people. I want the message to break on the screen when its sent so they will act on the problem immediately. The situation now requires them the continue to monitor their mail to get any updated messages.

I would be interested in either a programming solution or any products that might offer the break interface solution.


Thanks in advance for your advise.

Dave
9 REPLIES 9
Dave Kelly_1
Respected Contributor

Re: Unix mail solution where message breaks on screen

You can use the write command, i.e.

echo message | write user


If the user is logged on more than once, use the who command to determine the name of the terminals and then:

echo message | write user terminal
Carol Garrett
Trusted Contributor

Re: Unix mail solution where message breaks on screen


If you use email you become reliant on your mail server/process. If your mail setup is mission critical then your ok, if not then its unreliable.

We use a combination, email and popups on peoples X displays;

/usr/local/bin/xdialog -display orion:0 -bg red -fg black -t "************BACKUP FAILED**********" -m " BACKUP FAILED on $HOSTNAME "
Kofi ARTHIABAH
Honored Contributor

Re: Unix mail solution where message breaks on screen

David:

A really trivial solution might be something like this:

send a message to the terminal that operator is logged in as.
1. find out the tty where operator is logged in:
TTY=/dev/`who | grep ops | awk '{ print $2 }'` #where ops is the account
2. EMAIL="The text of the email you want the operators to see..."
echo $EMAIL >> $TTY
3. Voila - you could make it also e-mail the message to their mailbox
with echo $EMAIL | mailx -s "Alert message" ops

Good luck
nothing wrong with me that a few lines of code cannot fix!
federico_3
Honored Contributor

Re: Unix mail solution where message breaks on screen

You can use the following :


term=`who -u | grep operator | awk '{print $2}' ( in order to see in which terminal the operators are logged on )

for i in $term
do
echo "WARNING.... " | write operator $i

done

You can also use either :
term=`who -u | grep operator | awk '{print $2}'
echo "WARNING.... " > /dev/$term

or send the warning to the operator imbox ( windows)

echo "warning. "| mailx -s "warning" imbox_address


ciao

Federico



Kevin Ernst
Regular Advisor

Re: Unix mail solution where message breaks on screen

'wall -g ' works well if these users are already all in some predefined group. Here, I put everyone who would be interested in seeing error messages and notifications broadcast in the 'admin' group.
Kevin Ernst
Regular Advisor

Re: Unix mail solution where message breaks on screen

'wall -g ' works well if these users are already all in some predefined group. Here, I put everyone who would be interested in seeing error messages and notifications broadcast in the 'admin' group.

Example:

wall -g admin <Last night's backup needs a new tape...
EOF
Kofi ARTHIABAH
Honored Contributor

Re: Unix mail solution where message breaks on screen

I guess my only problem with write and wall is that it is possible to disable them with "mesg n " which might not be desirable if its critical... my 2c.
nothing wrong with me that a few lines of code cannot fix!
Kevin Ernst
Regular Advisor

Re: Unix mail solution where message breaks on screen

Super-user is allowed to override regular users' 'mesg n's though, right?

A quick test on one of our workstations suggests this is so. (root can 'write' to a non-privileged user even if he has set 'mesg n')
Kofi ARTHIABAH
Honored Contributor

Re: Unix mail solution where message breaks on screen

You are absolutely right, Kevin.
nothing wrong with me that a few lines of code cannot fix!