LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 08:12 AM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
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, 05:37 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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 05:41 PM.
 
Old 08-14-2013, 06:25 PM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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, 07:31 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

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

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, 09:41 AM   #6
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

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

Original Poster
Rep: Reputation: 70
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, 10:34 AM   #8
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
edit function hangs
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:25 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
Open Source Consulting | Domain Registration