Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing mail -d -s inside a script...

Status
Not open for further replies.

bitterrob

Technical User
Apr 29, 2002
8
GB
Im writing a script that needs to read a mail, save it then do some processing on the saved file then delete the mail according to the results of the processing....
I was wondering if it were possible to write a script file so that you could do mail -s filename....(which cant be run as -s is a subcommand..... thankks in advance for any help
 
Not sure exactly what you are trying to do, but it sounds to me like it would be better done with procmail as the mail arrives. Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
Hi Rob,

Have you tried the "here document" way of doing things?

It's where you supply the keystrokes, that will control some program, within your script. Like this:

mail <<!
q
!

Everything down to the line containing just ! is fed to the program. In this case it simply quits. Mike
______________________________________________________________________
&quot;Experience is the comb that Nature gives us after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
thanks mike for your help. Unfortuately it doesnt appear to work.
what I typed in was
mail <<!
s temp
q
!
but it only created an ! file.
can you assist?

 
this is my whole script....
mail << !
s nextmail
q
!
tmp=`grep -c unixassessment2002 nextmail`
while tmp <> 0 do
emailaddy= `grep Reply-To: nextmail |sed -e &quot;s/Reply-To: //&quot;`
name=`grep NameToAdd nextmail |sed -e &quot;s/NameToAdd: //&quot;`
session=`grep Session nextmail |sed -e &quot;s/Session: //&quot;`
count='grep -c session table'
if count < 4 then
paste emailaddy session name > table
mail emailaddy
dear name, you have been added to the list at session. thankyou
<ctrl-D>
fi
done
 
or corrected a bit
mail << ReadMail
s nextmail
q
ReadMail
tmp=`grep -c unixassessment2002 nextmail`
while tmp <> 0
do
emailaddy= `grep Reply-To: nextmail |sed -e &quot;s/Reply-To: //&quot;`
name=`grep NameToAdd nextmail |sed -e &quot;s/NameToAdd: //&quot;`
session=`grep Session nextmail |sed -e &quot;s/Session: //&quot;`
count='grep -c session table'
if count < 4
then
paste emailaddy session name > table
mail $emailaddy
dear $name, you have been added to the list at $session. thankyou
<ctrl-d>
fi
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top