• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

*nix: How do you leave msg for users?

smp

Diamond Member
I want to leave a little note for a certain user on my box. I would ideally like it to show up just for that user and after they log in.
No MOTD, no issue.
? is there a way ?
 
There are 2 ways.

1. Email . . . I am sure you already knew this one.
2. Write a script that will check for the user when he/she logs in, with the write,grep,awk,sleep,nohup commands, and have it run in the background. If you are the root of the box, you are a done deal, if you are not, you may want to ask your root what the policies are regarding users running background processes.
In addition, if you are not root, the person you are trying to send the automated message to HAS to have the mesg y set, in their environment, otherwise the command will fail.

GL

/edit: fixed small boo-boo
/edit: fixed command name
 
heh.. thanks!

I am root. It's my own box, at home.
I didn't really understand that stuff though, you think you could lay it down for me laymen's terms? Or maybe just point me to a howto or something?
 
I am assuming you have written a script before. . .

You can write a script that goes into a loop and runs in the background. Like this:
# nohup <your_script> &

Within the script you are going to use the following shell commands to achieve your goal:

write: Allows you to send messages to other user consoles AS LONG AS the other user has console message enabled with the comand mesg y in their profile. If you are root you don't have to worry about the user having console messages enabled.
grep: Will allow you to find the user you are looking for by looking at the pattern that would match the user's name.
awk: Will allow you to delimit and extract the user name for a 'current user's logged in' type output. You can either use it in combination with the who or finger command.
sleep: Will tell the script how often you want the script to wait, before checking for the user in the system again.
nohup: Will prevent the process from being killed by outside influence, but not by itselt. However, root can kill anything.

All of this will be, of course, within a loop, of your choice, that will continuously check for the user, and when the task succeeds, then it exits.
For more information, do a man on all of the commands I listed, and try to write it. If you need help debugging it, I would be happy to help you.

/edit: fixed bad sentence
 
or since he sounds like he want a simple answer..... he could just add an echo to the .bashrc (or whatever rc) file of the user. I mean its not an elegant solution, but easy to understand/implement.
 
That is true, but admin ethics would prohibit me from doing that. This action would fall under violation of privacy. However, in this case, since it is a personal computer, I dont know what kind of ethics he would like to get accustomed to. I just thought it would be best to do it this way. The admin way.

😉
 
I appreciate Abztrak's input, and it would seem easier. It is my own box, so admin ethics are what I make them.

I think I'll try LNXman's method though. It seems like the 'right' way to do it. Not only that, but if I'm going to do anything, I might as well learn while I'm at it. Script writing I have not really done. Editing scripts, yes, but writing my own from scratch, no.

I'll get back to you. I'm at school now, so I'll tackle this tonight maybe.
Thanks a lot.

edit: I think that this would be a useful script to hang onto as well, a good learning experience no doubt.
 
I don't recommend the script LNXman suggested. What if the script sends the message to the user when that person is not paying attention for numerous reasons (ie. in middle of a large scrollback, looses connection while in the john, etc). And if the user gets the message, how would he know how to respond to you?

Instead, I would recommend LNXman's first suggestion, a local email server. Email has long proven to work, and work well. It will be more reliable and useful than a simple shell script. If you decide to go the smtpd path, I suggest qmail. But if it's for a small system or something, something smaller like Exim might work fine.
 
Back
Top