what is effect of mail command
my OS has two users root & lxuser.If I become root in terminal and run 'mail lxuser'(without quotes ofcourse).then how will lxuser come to know of mail.
|
Every user has a folder in /var/mail (so /var/mail/root, /var/mail/usera, /var/mail/userb and so on), so they could check there.
|
Does that mean in my example lxuser has to check in /var/mail/lxuser & will not be notified in any way like during login or on X GUI?
|
Bash can check. From "man bash":
MAILCHECK Specifies how often (in seconds) bash checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking. MAILPATH A colon-separated list of file names to be checked for mail. The message to be printed when mail arrives in a particular file may be specified by separating the file name from the message with a `?'. When used in the text of the message, $_ expands to the name of the current mailfile. Example: MAILPATH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"' Bash supplies a default value for this variable, but the loca- tion of the user mail files that it uses is system dependent (e.g., /var/mail/$USER). |
I became root in terminal using 'su'(without quotes obviously)
Then I mailed user 'abhiluv' as follows #mail abhiluv Subject: hi what is going on ? <pressed ctrl+d> Cc: root #ls -aps /var/mail 8 ./ 8 ../ 0 abhiluv 4 cdot 8 root 4 rpc Why my mail did not appear ? |
Sumeet, the mail should be there in the file /var/mail/abhiluv. You can view that either by using the command "cat /var/mail/abhiluv" or by entering the command "mail" from abhiluv's shell.
Eg: [abhiluv@localhost ~]$ mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/abhiluv": 1 message > 1 root Thu Dec 17 13:29 21/746 "hi" & Entering "1" will display the first e-mail for abhiluv. If you prefer you can use other email clients like "pine" for viewing the e-mails. |
As shown above size of abhiluv is 0 bytes but still as 'aneeshk_k' says I tried
Code:
$mail Code:
#whoami Don't you think it should be 'no mail for root'? |
in ubuntu 9.04 I installed
#apt-get install mailutils Then I send mail to lxuser as root and it worked. But why does it not happen RHEL 5.3 I have noticed that in both OS echo $MAILPATH returned nothing so can't find mistake in RHEL 5.3 ? |
Quote:
|
I think I will have to append following line in ~/.bash_profile
MAILPATH=$MAILPATH:/var/mail/lxuser?"lxuser got mail" Am i right? I noticed that if I open terminal then message will come only after I run some command(like ls or anything)not by itself automatically.Can we colour the message so noticeable? Or should I be contented to run 'mail' like we check in our yahoo,gmail etc. accounts with web browser |
That's the way it works in Bash. The reason is that it doesn't want to interrupt you mid-command.
I keep looking for another easy way to monitor a changing file or directory. It seems to me that there ought to be some command line thing, but if there is, I don't know of it. While we're waiting for someone to point out what I missed, take a look at http://aplawrence.com/Unixart/watchdir.html That has links for dnotify, inotify, changedfiles, watch, Gamin and fam. None of those directly do what you want, but any of them could be used to roll up something. |
correction
Quote:
|
All times are GMT -5. The time now is 07:39 PM. |