LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-17-2006, 11:24 AM   #1
Jim Miller
Member
 
Registered: Sep 2001
Posts: 35

Rep: Reputation: 15
Running "mail" from a shell script?


I have procmail and spamassassin (under Fedora Core 4) diverting much of my spam into a folder where I can look at it later. What I'd like to have is a cron job that, every night, will create a "mail"-type listing of all the message summaries in that folder. What I want is the kind of summary you get when you first start "mail" -- message number, sender address, message date, message size, and message subject.

Is there a way to do this? The following comes pretty close:

Code:
echo 'q' | mail -f spam.folder > spam.output
but it only prints the information for the first 20 messages in the folder (you're supposed to interactively do a "z+" to see the next 20) and it's only displaying the first 20 characters of the message subjects (why it's doing this, I have no idea).

I suppose I could grep through the folder for "Subject:" lines or somesuch, but the output from mail is close enough that I'd like to use it if I can. Any thoughts?
 
Old 08-17-2006, 02:51 PM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
From "man mail":
Quote:
-H Print header summaries for all messages and exit.
Edit: Here mail is a link to nail, and that switch seems to be a nail extension. Maybe you should have a look for that program.

Last edited by spirit receiver; 08-17-2006 at 03:29 PM.
 
Old 08-17-2006, 03:30 PM   #3
Jim Miller
Member
 
Registered: Sep 2001
Posts: 35

Original Poster
Rep: Reputation: 15
That sounds like exactly what I want, but it's not available in "mail" under Fedora Core 4. (rpm: mailx-8.1.1-44) For whatever reason, I have a man page for mailx that lists the -H option, but it doesn't work with "mail". Is mailx hiding somewhere in my system, and I just haven't found it?
 
Old 08-17-2006, 03:37 PM   #4
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
I don't know anything about Fedora, but "rpm -lq mailx" will hopefully give you a list of all files delivered with that package.
 
Old 08-17-2006, 04:45 PM   #5
Jim Miller
Member
 
Registered: Sep 2001
Posts: 35

Original Poster
Rep: Reputation: 15
Here's what I get:

Code:
# rpm -lq mailx
/bin/mail
/etc/mail.rc
/usr/bin/Mail
/usr/lib/mail.help
/usr/lib/mail.tildehelp
/usr/share/man/man1/Mail.1.gz
/usr/share/man/man1/mail.1.gz

# /bin/mail -H 
/bin/mail: invalid option -- H
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user]
Sigh. Thanks for the help, in any case.
 
Old 08-18-2006, 04:31 AM   #6
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
As an alternative, consider using Perl and the Email::Folder module. See if you can get that module installed (from http://www.cpan.org/modules, try using the CPAN shell with "perl -MCPAN -e shell"). After that, it will only take a few lines of Perl code to do what you want.
 
  


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
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
shell script question: removing a line according to a duplicate "field" mattie_linux Linux - Newbie 1 01-12-2006 03:57 PM
Shel script mail send ("/" in mail address) problem anaid Linux - Networking 3 08-23-2005 07:41 AM
Starting Java from shell script (Exception in thread "main") rolf_mueller Linux - Software 5 10-30-2004 02:11 AM
err on running "perl -MCPAN -e shell" wellblue88 Linux - Newbie 0 09-21-2004 01:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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