LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-16-2009, 09:59 AM   #1
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Rep: Reputation: 48
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.
 
Old 12-16-2009, 10:04 AM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
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.
 
Old 12-16-2009, 10:29 AM   #3
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
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?
 
Old 12-16-2009, 10:53 AM   #4
pcunix
Member
 
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149

Rep: Reputation: 23
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).
 
1 members found this post helpful.
Old 12-17-2009, 02:49 AM   #5
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
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 ?
 
Old 12-17-2009, 03:02 AM   #6
aneeshk_k
LQ Newbie
 
Registered: Oct 2004
Posts: 17

Rep: Reputation: 1
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.
 
Old 12-17-2009, 03:06 AM   #7
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
As shown above size of abhiluv is 0 bytes but still as 'aneeshk_k' says I tried
Code:
$mail
No mail for abhiluv
I think cc means to send a copy so as you must have seen I sent even to root.

Code:
#whoami
root
#mail
No mail for abhiluv
Why does this happen ?
Don't you think it should be 'no mail for root'?

Last edited by sumeet inani; 12-17-2009 at 03:31 AM.
 
Old 12-17-2009, 03:25 AM   #8
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
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 ?

Last edited by sumeet inani; 12-17-2009 at 03:33 AM.
 
Old 12-17-2009, 06:58 AM   #9
pcunix
Member
 
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149

Rep: Reputation: 23
Quote:
Originally Posted by sumeet inani View Post
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 ?
So set it yourself in .bash_profile
 
Old 12-18-2009, 01:54 AM   #10
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
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

Last edited by sumeet inani; 12-22-2009 at 12:13 AM.
 
Old 12-18-2009, 04:08 AM   #11
pcunix
Member
 
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149

Rep: Reputation: 23
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.
 
Old 12-19-2009, 04:27 AM   #12
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
correction

Quote:
Originally Posted by XavierP View Post
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.
small mistake I found that there is a file named /var/mail/<username>.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian etch - Unable to send mail from command line or from php mail command lqforumuser Linux - Newbie 1 03-01-2009 07:56 AM
Want to send mail with php mail() command - minimum config required? FeathersMc Linux - Server 2 10-26-2008 01:21 AM
can mail command be used to send mail onto global mail servers like yahoo etc dale_chip Linux - Newbie 4 08-12-2008 09:33 AM
command line email client to send mail to remote mail server dhanju Linux - Software 1 03-07-2008 07:37 AM
No effect when 'export' command executed in a script? sylvain_gnu Linux - Software 6 04-20-2004 08:15 PM


All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration