473,394 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

communicating with another uside aside from the "wall" and "write" command

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...
May 11 '07 #1
3 2622
Motoma
3,237 Expert 2GB
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...
May 11 '07 #2
Motoma
3,237 Expert 2GB
Take a look at this script that I whipped up:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/bash
  2. # File:
  3. #   massmesssage.sh
  4. #
  5. # Usage:
  6. #   massmessage.sh user_name message_file
  7. #
  8. # Purpose:
  9. #   Sends the body of message_file to user_name via the write command
  10. #   Written by Motoma in response to a question on TheScripts.com
  11.  
  12.  
  13. USERNAME=$1
  14.  
  15. function getUsers()
  16. {
  17.   who | grep $USERNAME | awk '{print $1,$2}'
  18. }
  19.  
  20. while read user terminal ; do
  21.   cat $2 | write $user $terminal
  22. done<<EOF
  23. $(getUsers)
  24. EOF
  25.  
May 11 '07 #3
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!
May 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
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 -- ...
32
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...
81
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...
10
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...
0
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...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.