Operating System - HP-UX
1829601 Members
1809 Online
109992 Solutions
New Discussion

Re: Prompt message to a particular user terminal

 
SOLVED
Go to solution
Melvin Thong
Advisor

Prompt message to a particular user terminal

Scenario Descriptions
===============
I am required to write a shell script where it will prompt error message with a beep sound to selected user terminals when error encountered for a transfer file process using rcp command. Of course the user must log into the HP server via telnet session. If error occur in the rcp command when copying files over to a remote server, error message must be prompted to the telnet session on the particular terminal.

For example, I was given two IP addresses of the terminals to be propted with error mesage - 10.200.75.133 and 10.200.75.135.

Problem Descriptions
===============
My question is whether there is a way to detect from the HP server for these two given IP addresses to be prompted with error message when error ecountered.

I have tried using the "who" command, unfortunately it shows only the user id, tty and the date columns.

Is there a Unix command that I can grep for the terminal IP address when the user log in to the server via the terminal (10.200.75.133) as well as the user id and the tty for that session? I need to know that in order for me to use the "write" command to send a message to the user id and the tty that is using the 10.200.75.133 terminal. eg: cat msgfile.txt | write

Another problem is how should I create a beep sound when the error message is prompted onto the telnet session using the "write" command? Is there a way to create a beep sound with message on a telnet session for a specific terminal?

Please feel free to suggest if there is other better way to accomplish the above mentioned requirement. Thank you in advance!
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: Prompt message to a particular user terminal

Hi:

'who -u' will return a broader set of information, including the IPAddress (or DNS name) of the user's telnet session.

From this you can extract (with 'cut' or 'awk') the corresponding terminal to which to issue a write.

In general, if you do the following, you can add an audible beep to a message.

# echo "hello!\007"

I'm not sure whether the 'write' will pass this alone or whether it will be dropped, but you can try it.

...JRF...
linuxfan
Honored Contributor

Re: Prompt message to a particular user terminal

Hi Melvin,

you could try this

who -R | egrep "10.200.75.133" | awk '{print $1, $2}' | while read user terminal^Jdo^Jecho "rcp failed\007" | write $user $terminal^Jdone


To put this in a shell script

/Begin/
#!/bin/sh

who -R |egrep "10.200.75.133|10.200.75.135" | awk '{print $1, $2}' | while read user terminal
do
echo "rcp failed\007" | write user terminal
done

/END/

-HTH
I am RU
They think they know but don't. At least I know I don't know - Socrates
linuxfan
Honored Contributor
Solution

Re: Prompt message to a particular user terminal

Hi Melvin,

you could try this

who -R | egrep "10.200.75.133" | awk '{print $1, $2}' | while read user terminal^Jdo^Jecho "rcp failed\007" | write $user $terminal^Jdone


To put this in a shell script

/Begin/
#!/bin/sh

who -R |egrep "10.200.75.133|10.200.75.135" | awk '{print $1, $2}' | while read user terminal
do
echo "rcp failed\007" | write $user $terminal
done

/END/

-HTH
I am RU
They think they know but don't. At least I know I don't know - Socrates