Solved

Check file size of /var/spool/mail files

Posted on 2004-09-30
6
399 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now