communicating wth another user aside from "wall" and "write"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting communicating wth another user aside from "wall" and "write"
# 1  
Old 05-10-2007
Question communicating with another user aside from "wall" and "write"...

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) is not logged in to the same host as the receiver (but the exact hostname of the receiver is determined)
3. I want the message to appear on all terminals of the intended receiver.

Thanks in advance for your ideas...

Last edited by Deanne; 05-11-2007 at 01:03 AM..
# 2  
Old 05-10-2007
Question communicating wth another user aside from "wall" and "write"

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) is not logged in to the same host as the receiver (but the receiver's host is known)
3. I want the message to appear on all terminals of the intended receiver.

Thanks in advance for your ideas...

Last edited by Deanne; 05-11-2007 at 01:05 AM..
# 3  
Old 05-11-2007
my lord this is ugly - but i am sleepy, so take it or leave it Smilie.

there is probably a better solution, however given what comes standard on a unix system (talk, write and wall) - writing a script around 'write' would work... something like the following:

Code:
#!/bin/ksh

user=$1   # 1st arg, recipient
file=$2   # 2nd arg, file containing message

if [[ ! -n "${user}" ]]; then
        echo "you did not enter a user, aborting"
        exit 0
fi

# if no file, enter one line to send
#
if [[ ! -f "${file}" ]]; then
        echo "enter a one line message to send to ${user}"
        read line
        if [[ -n "${line}" ]]; then
                echo "${line}" > $0.$$
                file=$0.$$
        else
                echo "you did not enter any text, aborting"
                exit 0
        fi
fi

# write the file to all sessions of the user
#
for u in $(who | grep "^${user} " | awk '{print $1":"$2}'); do
        a=$(echo "${u}" | cut -d: -f1,1)
        b=$(echo "${u}" | cut -d: -f2,2)
        cat ${file} |write $a $b
done

# remove temp file if exists
#
if [ -f $0.$$ ]; then
        rm $0.$$
fi

# 4  
Old 05-11-2007
Thanks TinWalrus!

I already have the script for determining the specific user (in a specific host) and the file, so I just have to find a way to send.

# write the file to all sessions of the user
#
for u in $(who | grep "^${user} " | awk '{print $1":"$2}'); do
a=$(echo "${u}" | cut -d: -f1,1)
b=$(echo "${u}" | cut -d: -f2,2)
cat ${file} |write $a $b
done

# remove temp file if exists
#
if [ -f $0.$$ ]; then
rm $0.$$
fi


This is very helpful. Will translate this to cshell and play around with it.

Question. The for-loop uses "who" and "write"... it means sender should be remotely logged in to the same host of the receiver ? What part determines the host to which to send the message?
# 5  
Old 05-11-2007
Deanne, no cross-posting please. I have merged the threads.
# 6  
Old 05-11-2007
i apologize...
# 7  
Old 05-11-2007
errrrrr............the code wont work because the sender of the notice wont be logged in the same host as the recipient...

does anyone have any more tips?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. UNIX for Dummies Questions & Answers

What is the significance of sh -s in ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh?

Please can you help me understand the significance of providing arguments under sh -s in > ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh (4 Replies)
Discussion started by: Sree10
4 Replies

5. Shell Programming and Scripting

Problems with "write" and "wall"

Hello, I am using VirtualBox to simulate a small network with two Linux computers, the host is Mac OS X. My problem is that I can't send "write" and "wall" messages from the host to one of those Linux computers. Here is what works: - The virtual Linux computer answers "ping" messages that have... (5 Replies)
Discussion started by: 123_abc
5 Replies

6. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

9. UNIX for Dummies Questions & Answers

Need info:"talk,write and wall"

hi nu 2 this forum., can any one tell me how to 'talk' to a person on other system who is connected in a network(LAN) via terminal....... and when to use wall,write and talk.. regards leenus :) (1 Reply)
Discussion started by: mr.anilbabu
1 Replies
Login or Register to Ask a Question