Re: MAILX on an AIX server with arguments



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 ] && {
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

  • MAILX on an AIX server with arguments
    ... # MAILX.SH - generic shell to perform mailx with attachments. ... # 1 filename to use as e-mail body (needs fully qualified pathname). ... echo $command ...
    (comp.unix.shell)
  • Re: MAILX on an AIX server with arguments
    ... On Tue, 26 Sep 2006 13:16:30 GMT, Scott McMillan ... # MAILX.SH - generic shell to perform mailx with attachments. ... # 1 filename to use as e-mail body (needs fully qualified pathname). ... echo "$mfile"> $afile.uu ...
    (comp.unix.shell)
  • Simple bash problem.
    ... echo "Caught signal!" ... This e-mail and any attachments may contain confidential and/or ... NPL Management Ltd. Registered in England and Wales. ... Registered Office: Serco House, 16 Bartley Wood Business Park, ...
    (RedHat)
  • Re: My mail recipients cannot open Word documents sent as attachme
    ... Echo ... >>> Too many of my mail recipients say that they cannot open my Word files ... >>> as attachments or jpg files that I may send. ... >> Echo [MS PPT MVP] ...
    (microsoft.public.office.misc)