The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-10-2007
Deanne Deanne is offline
Registered User
  
 

Join Date: May 2007
Posts: 31
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 12:03 AM..
  #2 (permalink)  
Old 05-10-2007
Deanne Deanne is offline
Registered User
  
 

Join Date: May 2007
Posts: 31
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 12:05 AM..
  #3 (permalink)  
Old 05-10-2007
TinWalrus TinWalrus is offline
Registered User
  
 

Join Date: May 2007
Posts: 35
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
  #4 (permalink)  
Old 05-10-2007
Deanne Deanne is offline
Registered User
  
 

Join Date: May 2007
Posts: 31
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 (permalink)  
Old 05-10-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Deanne, no cross-posting please. I have merged the threads.
  #6 (permalink)  
Old 05-10-2007
Deanne Deanne is offline
Registered User
  
 

Join Date: May 2007
Posts: 31
i apologize...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0