Operating System - HP-UX
1833589 Members
3706 Online
110061 Solutions
New Discussion

scripting: how to mail an file as attachment on hp-ux

 
SOLVED
Go to solution
Stephan_K
HPE Pro

scripting: how to mail an file as attachment on hp-ux

Hi,

I want to write an script which mails an tar to file to some email-addresses. How does it works ?
I read man mailx but found no way. Any idea ?
Thanx in adv.
Regards
Stephan
I am an HPE employee.
5 REPLIES 5
MARTINACHE
Respected Contributor

Re: scripting: how to mail an file as attachment on hp-ux

Hi,

Try this :

http://hpux.connect.org.uk/hppd/hpux/Users/mpack-1.5/

Regards,

Patrice MARTINACHE
Patrice MARTINACHE
Jean-Louis Phelix
Honored Contributor

Re: scripting: how to mail an file as attachment on hp-ux

Hello,

I also often use mpack, but for a simple tar file you could use :

shar -cZ tar_file | mailx -s "subject" email

regards,

Jean-Louis.
It works for me (© Bill McNAMARA ...)
Paula J Frazer-Campbell
Honored Contributor
Solution

Re: scripting: how to mail an file as attachment on hp-ux

Hi

This is a small script, which will do what you require.

#!/bin/sh
MAILFILE=/tmp/mailtemp
HEADER=/tmp/header
clear
echo "Enter the email address: \c"
read TO
echo "Enter the Cc email address: \c"
read CC
echo "Enter the Bcc email address: \c"
read BCC
echo "Enter the Subject: \c"
read SUBJECT
echo "Enter the Body: \c"
read BODY
echo "Enter the filename of the attachment: \c"
read DATAFILE
echo To: $TO >> $HEADER
echo Cc: $CC >> $HEADER
echo Bcc: $BCC >> $HEADER
echo Subject: $SUBJECT >> $HEADER
echo "" >> $HEADER
echo "" >> $HEADER
echo $BODY >> $HEADER
echo "" >> $HEADER
cat $HEADER > $MAILFILE
uuencode $DATAFILE $DATAFILE.doc >> $MAILFILE
cat $MAILFILE | /usr/lib/sendmail -t
rm $MAILFILE
rm $HEADER



I got this from the forum but cannot remember from whom, so apologies to initial author.

Paula
If you can spell SysAdmin then you is one - anon
Darrell Allen
Honored Contributor

Re: scripting: how to mail an file as attachment on hp-ux

Hi Stephan,

I gleaned this from the forums a couple of weeks ago, particularly from posts of Rita C. Workman. It works well.

Create an "include" file containing this line:
[include dla.tar application/octet-stream base64]

Then do:
elm -s "tar file" someone@somewhere.com
Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Yogeeraj_1
Honored Contributor

Re: scripting: how to mail an file as attachment on hp-ux

hi,

please find attached an example script.

hope this helps!

Regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)