|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 (permalink) |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|