PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Send a message to a user's terminal
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Send a message to a user's terminal

Réponse
 
LinkBack Outils de la discussion
Vieux 21/08/2006, 17h38   #1 (permalink)
gineraso
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Send a message to a user's terminal

I wrote a scipt to kick unauthorized user's off my Solaris 9
workstation. Before I kill their session, I'd like to send a message
to their session with something like: "You are not authorized to use
this workstation. Your session will be killed."

I've tried talk but I just want to send one message from command line
Something like:

echo "You are not authorized to use this workstation. Your session will
be killed." {Session}

Any suggestions?

Thank you.

  Réponse avec citation
Vieux 21/08/2006, 18h36   #2 (permalink)
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Send a message to a user's terminal

On 21 Aug 2006 09:38:24 -0700, gineraso
<gineraso@gmail.com> wrote:
> I wrote a scipt to kick unauthorized user's off my Solaris 9
> workstation. Before I kill their session, I'd like to send a message
> to their session with something like: "You are not authorized to use
> this workstation. Your session will be killed."
>
> I've tried talk but I just want to send one message from command line
> Something like:
>
> echo "You are not authorized to use this workstation. Your session will
> be killed." {Session}
>
> Any suggestions?
>

If your script runs as root, you can get the device name of the user's
tty, and redirect the echo to that device. Or, if the user is using X,
open an xterm displaying the message on their display (you'll have to
use xauth).


--
The less time planning, the more time programming.
  Réponse avec citation
Vieux 21/08/2006, 20h27   #3 (permalink)
gineraso
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Send a message to a user's terminal

That worked really well:

echo "Get the hell off my server!!" > /dev/pts#/#

Thank you.

Bill Marcum wrote:
> On 21 Aug 2006 09:38:24 -0700, gineraso
> <gineraso@gmail.com> wrote:
> > I wrote a scipt to kick unauthorized user's off my Solaris 9
> > workstation. Before I kill their session, I'd like to send a message
> > to their session with something like: "You are not authorized to use
> > this workstation. Your session will be killed."
> >
> > I've tried talk but I just want to send one message from command line
> > Something like:
> >
> > echo "You are not authorized to use this workstation. Your session will
> > be killed." {Session}
> >
> > Any suggestions?
> >

> If your script runs as root, you can get the device name of the user's
> tty, and redirect the echo to that device. Or, if the user is using X,
> open an xterm displaying the message on their display (you'll have to
> use xauth).
>
>
> --
> The less time planning, the more time programming.


  Réponse avec citation
Vieux 21/08/2006, 20h33   #4 (permalink)
Chris Mattern
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Send a message to a user's terminal

Bill Marcum wrote:
> On 21 Aug 2006 09:38:24 -0700, gineraso
> <gineraso@gmail.com> wrote:
>
>>I wrote a scipt to kick unauthorized user's off my Solaris 9
>>workstation. Before I kill their session, I'd like to send a message
>>to their session with something like: "You are not authorized to use
>>this workstation. Your session will be killed."
>>
>>I've tried talk but I just want to send one message from command line
>>Something like:
>>
>>echo "You are not authorized to use this workstation. Your session will
>>be killed." {Session}
>>
>>Any suggestions?
>>

>
> If your script runs as root, you can get the device name of the user's
> tty, and redirect the echo to that device. Or, if the user is using X,
> open an xterm displaying the message on their display (you'll have to
> use xauth).
>
>


Or you can use write. This may not work, depending on how your
system is configured. Since write talks to a terminal, it
also won't work if your user is logged on to an X display
manager and has no terminals up, since there's nobody to
write to. It will find his pseudo-terminal if he's running
a terminal emulator in X, however.


Chris Mattern
  Réponse avec citation
Vieux 21/08/2006, 22h40   #5 (permalink)
johngnub
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Send a message to a user's terminal


gineraso wrote:
> I wrote a scipt to kick unauthorized user's off my Solaris 9
> workstation. Before I kill their session, I'd like to send a message
> to their session with something like: "You are not authorized to use
> this workstation. Your session will be killed."
>
> I've tried talk but I just want to send one message from command line
> Something like:
>
> echo "You are not authorized to use this workstation. Your session will
> be killed." {Session}
>
> Any suggestions?
>
> Thank you.


This worked on my SCO systems, pls forgive the long command line,
who -a|tr -s ' ' |cut -d ' ' -f1,3|grep tty |{ while read dude term; do
echo "$dude $term"; echo "foo"|write $dude $term; done; }

>From who -a command, get the name and tty, the pipe that to while, read

the vars, dude and term, then feed them to the write command. If you
mod the grep, then you can write to only that one user name, ( grep tty
-> grep johnb) write wanted some input , thus I feed it with a "echo
"fun" |write $dude $term". The tr -s was to safe guard extra spaces
from messing up my cut.

Looks like a lot, but it has worked well for me, a simpler ver may drop
the dude and term to a file, then loop over the file.

For some fun!!
banner `date` to replace the echo "foo".

I am sure I will be mocked for a) still runnng SCO b) the long pipe and
while, etc.
2 cents. JB

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h03.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10112 seconds with 13 queries