The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with mail command hern14 UNIX for Dummies Questions & Answers 2 05-15-2008 06:25 AM
Mail command FeNiCrC_Neil UNIX for Dummies Questions & Answers 2 08-31-2007 10:12 AM
mail command on sco box benefactr UNIX for Advanced & Expert Users 0 08-17-2007 02:29 PM
mail command habuzahra UNIX for Dummies Questions & Answers 4 01-08-2007 05:00 AM
Help with mail command Rohini Vijay Shell Programming and Scripting 7 08-01-2006 01:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-23-2006
Registered User
 

Join Date: Apr 2006
Posts: 89
mail command

i wanted to write a shell script that can automatically read unread mails and copy each one into a different file. I was trying to use the MAIL command to do it, but this command requires user input inbetween, I was wondering how that could be achieved in a shell script.
Can sumone please help. its urgent. please.

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-23-2006
Registered User
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 130
I've written several different scripts each, more or less, achieving the same thing. The easiest solution I've found is to set up an alias which pipelines the message into a script. From there you can use whatever UNIX commands you want to parse, filter, and rename the message. If you want to include attachments in your parsing, you'll need to install metamail or some such program to extract the MIME encoded bits.

It's a direction, not a complete answer -- all of my "notes" are at work. I hope it helps.
Reply With Quote
  #3 (permalink)  
Old 04-23-2006
Registered User
 

Join Date: Apr 2006
Posts: 89
DOUBT - with the MAIL command

thanks a lot hegemaro but my problem was with the usage of the mail command. The MAIL command needs us to press the 'Enter' key or 'n' to move onto the next message once the present message has been viewed. How do I achieve this in order to automate the copying of successive mails. Can you please help.

THANKS...
Reply With Quote
  #4 (permalink)  
Old 04-23-2006
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
How about something like this?
Code:
 echo "t 1-`mail < /dev/null | grep Held | sed 's/Held \([0-9][0-9]*\) mes.*/\1/'`" | mail >/var/tmp/maillist
Cheers
ZB
Reply With Quote
  #5 (permalink)  
Old 04-24-2006
Registered User
 

Join Date: Apr 2006
Posts: 89
Thanks a lot for that. But how do i delete the mail that has just been copied onto the file so that i can move on to check for my next new mail.

Also how do i get rid of all the headers that form a part of the mail which are not reqd. These headers do not turn up when the mail command is used on its own.

Any help is welcome ... Thanks a looot ....

Last edited by garric; 04-24-2006 at 02:07 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:24 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0