Solved

Check file size of /var/spool/mail files

Posted on 2004-09-30
6
409 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 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

14 Experts available now in Live!

Get 1:1 Help Now