![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| Need info:"talk,write and wall" | mr.anilbabu | UNIX for Dummies Questions & Answers | 1 | 07-23-2006 04:27 AM |
| how could i make a program mixed with many "|", "<" and ">" | strugglingman | High Level Programming | 2 | 04-29-2006 08:11 AM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 04:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 12:03 AM.. |
|
||||
|
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 12:05 AM.. |
|
||||
|
my lord this is ugly - but i am sleepy, so take it or leave it
. 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
|
|
||||
|
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? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|