The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 10:25 AM
Mail command FeNiCrC_Neil UNIX for Dummies Questions & Answers 2 08-31-2007 02:12 PM
mail command on sco box benefactr UNIX for Advanced & Expert Users 0 08-17-2007 06:29 PM
mail command habuzahra UNIX for Dummies Questions & Answers 4 01-08-2007 09:00 AM
Help with mail command Rohini Vijay Shell Programming and Scripting 7 08-01-2006 05:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-23-2006
garric garric is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 99
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
  #2 (permalink)  
Old 04-23-2006
hegemaro hegemaro is offline
Registered User
  
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 134
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.
  #3 (permalink)  
Old 04-24-2006
garric garric is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 99
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...
  #4 (permalink)  
Old 04-24-2006
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
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
  #5 (permalink)  
Old 04-24-2006
garric garric is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 99
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 06:07 AM..
Closed Thread

Bookmarks

Tags
unix commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0