How to 'write' to a user, lgged from 'su'?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to 'write' to a user, lgged from 'su'?
# 1  
Old 02-02-2009
How to 'write' to a user, lgged from 'su'?

I have a situation, where some script (running background) need to use the 'write' command and get a text to appeared on any screen of some particular user.
Like:
Code:
>echo "$message"|write user1

But I surprisingly realized, that if a person logged under any other name and after that uses the 'su' command to log in as the 'user1', he will not be reachable by the 'write' command!

Is there any other way to send a message to anyone who currently logged as 'user1', even by 'su'?

Last edited by alex_5161; 02-02-2009 at 05:41 PM..
# 2  
Old 02-02-2009
Edit user1's $HOME/.login
# 3  
Old 02-02-2009
What do you mean, glen.barber?
What and with what intention anything should be edited?
# 4  
Old 02-02-2009
Quote:
Is there any other way to send a message to anyone who currently logged as 'user1', even by 'su'?
You can have a message displayed at login by editing $HOME/.login For instructions, read the login manpage for your particular OS.

As far as writing to a user's screen from a script, I'm not aware of a way to do that. You can send that particular user mail output in your script.
# 5  
Old 02-02-2009
Hi,
The write program writes text to a users tty. That is what the OP was talking about.
Yo should use the who command to figure out what terminal/xterm/whatever tty the user is using. The root user more often than not has messaging turned off by default. Use the mesg command to configure those rules.

And have a look at "man write" and "man mesg" Smilie

/Lakris

EDIT:
sorry, I guess I got carried away... I usually do an "ssh -X user@localhost" because I'm lazy and want X-forwarding, and then I always get a clean and obvious login. su'd users don't show up in who. So, I would find a way , with for example ps axjf to find the user You want to reach, find the tty, and find the owner of that tty...

this is very crude but I guess You get the idea...
Code:
lakris@landet:~$ ps axjf|grep 'su - grok'|grep -v grep
 7277  7300  7300  7277 pts/0     7306 S     1001   0:00      \_ su - grok
lakris@landet:~$ ps axu |grep 7277|grep -v grep
lakris    7277  0.0  0.3   5824  3200 pts/0    Ss   23:32   0:00 bash
lakris@landet:~$ write lakris pts/0
df sdf g
^Clakris@landet:~$

and in my other xterm it shows up as

Code:
lakris@landet:~$ su - grok
Password: 
grok@landet:~$ 
Message from lakris@landet on pts/2 at 23:44 ...
df sdf g
EOF

Hope it helps!

/L

Last edited by Lakris; 02-02-2009 at 06:53 PM..
# 6  
Old 02-02-2009
It is not a solution to my situation - to have anything appeares on user's loggin!
First - I need it displayed right away (assuming, someone use that log name - user1 - in every given point of time)
Second - the 'user1' is not logging on - someone uses 'su' to use that account for some tasks!
The 'write' command perfectly works out what I need - it is showing a message on first found screen (tty) for a requested user, BUT it is fooled by the 'su' loggin.

Whell, it is a production control task that should inform about itself in some condition.
And you can guess, in different time different people performe 'production control' duties.
I do not need to have it write for a particular individual, but to an anyone who currently use the production control loggin 'user1'.

Than why the 'mailx' also is not comfortable.

Is there any idias for that task?
# 7  
Old 02-02-2009
Lakris - thank you, now I've get it. I have to work through terminal and an actual user's id.
And thank you for example. I will try.

Glen, appreciate your responce, also!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Setting write permission for particular user

Hi All, We have a scenario in production where we want only one user from a group to modify the file. The file is not set to write permission for application manager. -r--r--r-- 1 amgr u00 15661716 Aug 30 00:06 DCI.dat So here amgr will have permission to edit the file. We want a... (10 Replies)
Discussion started by: arunkumar_mca
10 Replies

2. Shell Programming and Scripting

search any user files with write permission

Guys, i wanna get any user files with write permission (on user or group permission) for review but i confuse with -perm parameter. any body can help me to explain what is that mean? thank's (1 Reply)
Discussion started by: michlix
1 Replies

3. Shell Programming and Scripting

Write a scripts to kill idle user for 60 min. & email user list to admin in text file

Folks, I have written one script for following condition by referring some of online post in this forum. Please correct it if I'm missing something in it. (OS: AIX 5.3) List the idle user. (I used whoidle command to list first 15 user and get username, idle time, pid and login time).... (4 Replies)
Discussion started by: sumit30
4 Replies

4. Shell Programming and Scripting

Write a message on specific user terminal

Hi All, Need urgent help!!! Can anyone tellme how can we send a message on specific user terminal and get a response from user in return. Thanks in advance. (3 Replies)
Discussion started by: Sadhana
3 Replies

5. OS X (Apple)

Write message to another user on same network

On our home network, with 2 Macbook pros running OS X 10.6.*, I would like be able to popup a message to the user of the other computer. Is there a way I can "call" from one computer to another not using skype, or ichat or any application that the user has to have running? I guess first I... (8 Replies)
Discussion started by: allelopath
8 Replies

6. UNIX for Dummies Questions & Answers

How to find out in which directories a user can write?

Hi everybody, what command can show me the directories in which a certain user can write to? Kind Regards FranzB (2 Replies)
Discussion started by: FranzB
2 Replies

7. UNIX for Advanced & Expert Users

Possible to show in which directory a user can write?

Hi Gurus, is there a possibility to show where a user can write to? i want to see all directories where a user has permissions to write to. Kind Regards FranzB (0 Replies)
Discussion started by: FranzB
0 Replies

8. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

9. Shell Programming and Scripting

Is it possible to write a script to reset user's password?

Is there anyway that I can reset user's password using a script/ssh command? ie. emulate passwd command with a default password of abc123 or even null value? > ssh server1 pwdadm user1 < /dev/null or > ssh server1 passwd user1 < /dev/null neither worked for me.. but you know what I... (1 Reply)
Discussion started by: pdtak
1 Replies

10. UNIX for Dummies Questions & Answers

Write privilege for user

Is it possible to grant write privileges to a user on a directory with out having to add the user to a group or make the user the owner of the directory? My background is in Windows and in Windows you can grant specific privileges to a user without having to put the user in a group or making the... (3 Replies)
Discussion started by: here2learn
3 Replies
Login or Register to Ask a Question