LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 08-14-2013, 09:12 AM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,027

Rep: Reputation: 69
Any way to show when an email has been received via command line...


Hello,

I am running Slackware 13.37. I use mainly mutt to check my mail. I am using Maildir format. Is there a way to where each time I hit enter on the command line it checks to see if I have any mail and if I do to display I have mail? Sort of like biff but I think biff only works for mbox.

-Tristan
 
Old 08-14-2013, 06:37 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
The problem depends on where the mail is, not the file format.

If you use a remote server to retrieve your mail from (most people do), then whatever method you want has to actually download any mail messages (or ask the server how many)... And that will require whatever method the server requires to login. This is slow.

If it is local mail (as in /var/mail/<username>) then it is simple - just look at the file, if the size is bigger than the last check, you have new mail. If it is smaller, mail has been read - and use the new size. This is what the bash shell does for checking.

See the manpage on bash - it handles maildir format as well as mbox files.

Last edited by jpollard; 08-14-2013 at 06:41 PM.
 
Old 08-14-2013, 07:25 PM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Not sure about Bash, but Zsh knows the precmd (executed anytime before a prompt is printed) and preexec (executed anytime before the commandline is executed) functions, which could easily be used for your purpose. Of course it would be easier to run Mutt all the time in a different terminal/VT and check periodically for new mail manually.
 
Old 08-14-2013, 08:31 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Try post #5 here http://ubuntuforums.org/showthread.php?t=878058 ?
 
Old 08-15-2013, 12:33 AM   #5
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
I guess for gnome maybe this will work
http://ubuntuforums.org/showthread.php?t=195788
 
Old 08-15-2013, 10:41 AM   #6
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,027

Original Poster
Rep: Reputation: 69
Great thanks.
 
Old 08-15-2013, 11:29 AM   #7
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,027

Original Poster
Rep: Reputation: 69
For anybody interested, I found bash's solution. This of course assumes you are using bash as your shell.

Make sure these environmental variables are set

MAIL=~/Maildir
MAILCHECK=60

This will check your mailbox every 60 seconds and if you have mail it will display the next time you hit enter on the command line.

If you are using mbox make sure to use

MAIL=~/mbox

instead.

The reason it was not working for me earlier was because my MAIL variable was set to

MAIL=/var/mail/<username>

but once I changed it to my Maildir it worked.

Enjoy!

-Tristan

---------- Post added 08-15-13 at 10:29 AM ----------

For anybody interested, I found bash's solution. This of course assumes you are using bash as your shell.

Make sure these environmental variables are set

MAIL=~/Maildir
MAILCHECK=60

This will check your mailbox every 60 seconds and if you have mail it will display the next time you hit enter on the command line.

If you are using mbox make sure to use

MAIL=~/mbox

instead.

The reason it was not working for me earlier was because my MAIL variable was set to

MAIL=/var/mail/<username>

but once I changed it to my Maildir it worked.

Enjoy!

-Tristan
 
Old 08-15-2013, 11:34 AM   #8
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,027

Original Poster
Rep: Reputation: 69
edit function hangs
 
  


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
Show folder and only one subfolder using ls in command line Drigo Linux - Newbie 4 07-14-2011 01:56 PM
How to show bit-rate on mp3 files from the command line? bgoodr Linux - Software 18 09-26-2009 10:58 AM
Pipe'ing the ouput of 'cat' into 'mutt' (email) losses newlines when email received helptonewbie Linux - Newbie 2 08-28-2008 04:16 AM
ps doesn't show the full command line OlRoy *BSD 2 01-29-2007 10:34 PM
GRUB show me command line after rebooted darkranger Linux - General 10 09-08-2004 05:13 AM


All times are GMT -5. The time now is 09:18 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