Results 1 to 4 of 4
Hey guys,
I have a bit of an issue with this script:
Code:
MAILDIR="/var/spool/mail/lastname.firstname"
TEXT="Re:"
DESTDIR="~/Mail/DestFolder"
find "$MAILDIR" -type f | while read N #This will find my Mail and ...
- 11-18-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 3
Strange Problem
Hey guys,
I have a bit of an issue with this script:
I have no idea what is wrong. The Paths are correct. The commands seem to be ok.Code:MAILDIR="/var/spool/mail/lastname.firstname" TEXT="Re:" DESTDIR="~/Mail/DestFolder" find "$MAILDIR" -type f | while read N #This will find my Mail and read it #But to do that read needs a varaible. do #Begin the body of the while loop cat "$N" | grep -q "$TEXT" #Using N as the location of my mail if [ $? == 0 ]; then #If my text is matched at least once mv "$N" "$DESTDIR" #Move my inbox mail int my mail folder fi #end my if statement with fi done #end while
- 11-18-2008 #2Just Joined!
- Join Date
- Nov 2008
- Posts
- 3
one of the possibilites could be the find command and the type that im specifying. I should prolly be looking at the Mail level and not the file level.
Having a very hard time with this
- 11-19-2008 #3
I know I'm really showing my ignorance with this question, but do you need the quotes around each of the variables?
Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 11-20-2008 #4Just Joined!
- Join Date
- Nov 2008
- Posts
- 3
I took another approach because i knew what was happening.
If a single occurence of "whatever i had" is found by grep it will move EVERYTHING to the specifed directory.
This is a better approach taken by me accompanied by another:
Code:#!/bin/bash cat mbox | sed -r 's/From /END====From /' | sed -n 'H; ${g;s/\n/+=+/g;p}' |\ sed 's/END====From/END\nFrom /g' |\ egrep ".*Subject: Hello.*" |\ sed 's/+=+/\n/g' > ~/Mail/Destdir
exstatic.
On the other hand. A way that i can simplfy is to create the three golden files, ".forward , .promailrc , general.rc ".
Also:
I have three files, .forward ( in home ) .procmailrc and general.rc ( in my .procmail directory ) And im wondering if i can get my general.rc file to do the same thing as the above code. My general.rc looks like this:
What i think that file does is it looks for who the mail is from, whether or not hello is in the subject line and puts what it found into a Hello folder.Code::0 * ^From:.*sumone@sumaddy.com * ^Subject:.*hello $HOME/Mail/Hello
So my .forward looks like this:
Now the most important file .procmailrc that ties everything together is as follows:Code:"|IFS=' '&&exec usr/bin/procmail||exit 75 #username"
All three of these files work together to do the same task as the sed command script. And i know the problem might be with the general.rc i heard the grep and sed are built in?Code:VERBOSE=off MAILDIR=$HOME/Mail PMDIR=$HOME/.procmail DEFAULT=/var/spool/mail/username LOGFILE=$PMDIR/log INCLUDERC=$PMDIR/general.rc #end of .procmailrc
Any help ios appreciated!


Reply With Quote