zip and email files

Hi,
New to Unix and trying to do something -

I am trying to zip bunch of file and email -

/sbin/sh

If i use mail then I can not specify subject -

uuencode file.zip file.zip | mail -s "testfile" mailadd@group.com
Error is - mail: illegal option -- s

If i use mailx then I can specify subject but it truncates null char at the end of line which i dont want. and data is in message body and not as an attachment.

uuencode file.zip file.zip | mailx -s "My Report" mailadd@group.com

mailx: deleted 16 NULL characters in mail file

I am confused with lot of ways of mail in unix and looking exact commands for /sbin/sh

Help!

Thanks

Using:

mail -s "subject"

should be okay, is there anything in the user's ~/.mailrc file or in /etc/mail.rc that might be breaking it?

There's no "-s" switch to "mail" in mainstream unix.
What unix version is the o/p using?
What software produced the ".zip" file and was that software run on the unix server itself, or was the file copied from a Windows platform?
Is the mail engine "sendmail"?

you may want to lookup "mpack" too... that is what I use for scripted emailing with attached files.

mpack is not recognized.

Version Details

HP-UX sherman B.11.23 U 9000/800 2818424501 unlimited-user license
[HP Release B.11.23]

I think it uses sendmail. I tried using this but get permission denied message.

zip files are created in unix only. I am using zip command for that.

Here is a method to mail the file as an attachment with unix sendmail. I've tested the method with a file compressed with unix "compress", mailed the file as an attachment, saved the attachment and checked with unix checksum "cksum".

(
echo "From: `uname -n` ${LOGNAME}"
echo "Subject: Mail Test from `uname -n` `date`"
# The next line appears as the message body
echo "Zip file attached"
# The next line creates the attachment with a suitable extension
uuencode file.zip file.zip
echo "."
) | /usr/lib/sendmail mailadd@group.com

Looking at:

$ man mail

on the platform you are trying to send the mail from would confirm this either way.

Hi,
This works perfectly.:slight_smile:
Thanks you so much for your help.

Regards,
Bhushan

---------- Post updated 09-21-09 at 12:08 AM ---------- Previous update was 09-20-09 at 11:39 PM ----------

Hi methyl,

One more small help needed. I am using your code and its working perfectly. However I could not see to email address specified in email, after I receive email in my mailbox. From email address and subject/attachement/body all are visible.

Regards,

---------- Post updated at 12:14 AM ---------- Previous update was at 12:08 AM ----------

Got it......I changed as below -

(
echo "From: `uname -n` "
echo "Subject: Mail Test from `uname -n` `date`"
echo "To: abc@abc.com"
# The next line appears as the message body
echo "Zip file attached"
# The next line creates the attachment with a suitable extension
uuencode bank_Listing1.zip bank_Listing1.zip
echo "."
) | /usr/lib/sendmail -vt