Solved

Check file size of /var/spool/mail files

Posted on 2004-09-30
6
415 Views
Last Modified: 2010-04-21
Hi i want to print a user's /var/spool/mail/username file ie mine is /var/spool/mail/jerry , then delete it, but i only want to print it if the file size is greater than 0  or if it is easier if the file is empty . Is there anyway to do this through a cron job or the like that checks every 5 minutes.
Thanks,
Jerry
0
Comment
Question by:jerrycsakanyjr
  • 3
  • 2
6 Comments
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 12194221
Access to the mail spool file is a carefully orchestrated dance,
using file presence/absence, locking, and timestamps.  This
allows the various processes that access the spool file to do so
without corrupting its contents, dropping messages, etc.

Considerable care must be taken to avoid printing or reaping
a file with 1/2 a message appended, or deleting the file while
some mail client is fetching the data.

The spool file itself contains all unread mail concatenated one
after the other.  Formatted messages are encoded in a 7-bit
ASCII plain-text scheme like uue or base-64 as well as MIME
encoding issues.  In other words, simply sending the file to
lpr will probably not give you the most desirable result.
0
 

Author Comment

by:jerrycsakanyjr
ID: 12194279
The purpose of this is  We get confirmation of faxes sent via hylafax to the users home directory in the form of an email. I am trying to figure out how to auto print those confirms, since the users are on win2k stations and some don't even have email setup in outlook and don't have the time to check their emails, so if we could send those emails that are sent to the users home directory to the printer we would be golden. The queuer name is up-middle .  
0
 

Author Comment

by:jerrycsakanyjr
ID: 12194290
correction queue...sorry can't type ;)
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 23

Expert Comment

by:brettmjohnson
ID: 12194503
I think you want to look into creating a procmail script to do this type of task:

http://pegasus.rutgers.edu/~elflord/unix/procmail.html
http://userpages.umbc.edu/~ian/procmail.html

0
 

Author Comment

by:jerrycsakanyjr
ID: 12196305
I tried writing a procmailrc file that has the following

0:
* ^From:.fax@allstateabstract.com
| lpr -P up-middle

but it just doesn't seem to wanna work for me..what am i doing wrong?
0
 
LVL 38

Accepted Solution

by:
yuzh earned 500 total points
ID: 12196640
Do you want to print your email (jerry's email) only?

If it is the case, you can create a .forward file and put under jerry's home dir. the .forward
file (text file) with the following format:

"|/usr/bin/lpr -P up-middle -"


If you want to keep a copy of the email in your mail box, and only print the in coming email
make the file looks like:

jerry, "|/usr/bin/lpr -P up-middle -"


0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
read a word from a file in linux shell script 4 77
generating rpm using noarch parameter 1 40
what is this linux system is? 16 119
BASH script to modify crontab? 3 67
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question