Re: MAILX on an AIX server with arguments



Thanks Scott, I was missing the logical thought that I don't need to
check for an attachment if I'm using either /or for my bodyfile
statement.

long week and it's only Tuesday.

me

Scott McMillan wrote:
On Tue, 26 Sep 2006 13:16:30 GMT, Scott McMillan
<smcmillan@xxxxxxxxxxx> wrote:

On 25 Sep 2006 16:54:22 -0700, "DanceRat" <kimberly.shaffer@xxxxxxxxx>
wrote:

I'm having the darndest time with this but it seems like it would be a
simple thing I'm missing...

Basically, what I'm trying to do is have my cake and eat it too - if
there isn't a file for the body, (no mfile exists), then I want it to
just put whatever is typed out in argument #1 as the bodyfile - for
instance, I type in "this is a test" for the $1 argument and when it
sees that there isn't a file called "this is a test" it actually just
uses that string as the body.

Anyone have any ideas?



#!/bin/sh
# MAILX.SH - generic shell to perform mailx with attachments.
# requires module defined with 5 arguments
# 1 filename to use as e-mail body (needs fully qualified pathname).
# 2 filename to use as e-mail attachment (needs fully qualified
pathname).
# 3 subject line of e-mail.
# 4 space delimited e-mail "to" list
# 5 space delimited distribution lists (needs fully qualified
pathname).


mfile=$1
afile=$2
msubj=\'$3\'
mto=\'$4\'
catfiles=$5

command='mailx'

if [ "$afile" != "''" ]; then
[ -f "$mfile ] && {

should be

[ -f "$mfile" ] && {

cat "$mfile" > $afile.uu
} || {
echo "$mfile" > $afile.uu
}
uuencode $afile $afile >> $afile.uu
else
cat "Sorry, there were no attachments." > $afile.uu
fi

if [ "$msubj" != "''" ]; then
command=$command' -s '$msubj
else
command=$command' -s "E-Mail For You"'
fi

if [ "$mto" = "''" ]; then
command=$command' '`cat $catfiles`' < '$afile.uu
else
command=$command' '$mto' < '$afile.uu
echo $PWD
fi


err=$?
echo $command
eval $command
rm $afile.uu
err=$?
exit $err


I don't see that you reference mfile if there is no attachment, but
the same logic would apply there.


Scott McMillan

.



Relevant Pages