MAILX on an AIX server with arguments



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
cat "$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

.



Relevant Pages

  • 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)
  • Re: MAILX on an AIX server with arguments
    ... there isn't a file for the body, (no mfile exists), then I want it to ... # 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)
  • RE: Send emails with attachments from command line
    ... > Subject: SV: Send emails with attachments from command line ... use of the intended addressee and may contain confidential ...
    (freebsd-questions)
  • Re: odd error trying to load ALSA module
    ... # $2 DEV_DIR-relative pathname of destination ... echo -n "Creating $1..." ... minor=`expr $2 + $tmp` ... if is_dir snd; then ...
    (comp.os.linux.hardware)
  • How to write a page break character.
    ... How can I "write" the page break character on command line? ... >>end of each line how can I remove these charaters, ... The information contained in this electronic message and any attachments to this message are intended ... you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately ...
    (perl.beginners)