Hi,
Can anyone suggest a Unix command or c-shell algorithm to simulate to behavior of "wall" command minus the "all users"? What I'm trying to do is to send a notice to just one particular user but i dont want other remotely-logged-on users to receive the message (on the pseudo-terminals). I cannot use the "write" command for three reasons:
1. I (sender) will not be typing the message from standard input (instead, i will be using a file
input)
2. I (sender) dont want to do rlogin
3. I want the message to appear on all terminals of the intended receiver.
Thanks in advance for your ideas...
3 2622
None of these seem to be reasons why you cannot use write. Perhaps you could explain better what you are trying to do (I am assuming automated global messages) and I will do my best to show you how.
Hi,
Can anyone suggest a Unix command or c-shell algorithm to simulate to behavior of "wall" command minus the "all users"? What I'm trying to do is to send a notice to just one particular user but i dont want other remotely-logged-on users to receive the message (on the pseudo-terminals). I cannot use the "write" command for three reasons:
1. I (sender) will not be typing the message from standard input (instead, i will be using a file
input)
2. I (sender) dont want to do rlogin
3. I want the message to appear on all terminals of the intended receiver.
Thanks in advance for your ideas...
Take a look at this script that I whipped up: -
#!/usr/local/bin/bash
-
#
-
# File:
-
# massmesssage.sh
-
#
-
# Usage:
-
# massmessage.sh user_name message_file
-
#
-
# Purpose:
-
# Sends the body of message_file to user_name via the write command
-
# Written by Motoma in response to a question on TheScripts.com
-
-
-
USERNAME=$1
-
-
function getUsers()
-
{
-
who | grep $USERNAME | awk '{print $1,$2}'
-
}
-
-
while read user terminal ; do
-
cat $2 | write $user $terminal
-
done<<EOF
-
$(getUsers)
-
EOF
-
Thanks Motoma!
Yes I have seen how I can use write considering conditions 1 and 3... but not 2 (yet).
I use exactly the same algorith as the one who suggested:
1. who-pipe-grep-pipe-awk
2. In a foreach loop, do:
2a. get the pts
2b. cat-pipe-write
Now I have a couple questions related to the way the message is displayed...
- Unlike when I use "wall", there is some extra spaces written at the beginning of the line "Message from ...." How can I remove these extra spaces?
- How can I keep the <EOT> string from being displayed?
Do you have any ideas? Thanks again!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alf P. Steinbach |
last post by:
The fourth part of my attempted Correct C++ tutorial is now available,
although for now only in Word format (use free Open Office if no Word),
and also, it's not yet been reviewed at all -- ...
|
by: Mike Machuidel |
last post by:
Hi,
I'm a game developer programming mostly in C and ASM for about 7 years.
Today at work a colleague (a C++ programmer) yelled at me I'm a bad C
programmer because I use "return(0);" instead...
|
by: Matt |
last post by:
I have 2 questions:
1. strlen returns an unsigned (size_t) quantity. Why is an unsigned
value more approprate than a signed value? Why is unsighned value less
appropriate?
2. Would there...
|
by: eyh5 |
last post by:
Hi,
My C code (running on Soalris Unix) has some "segmentation fault"
that I wish to use purify to do it. I poked around the web, and found
some information about adding some lines in a Makefile...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |