How to attach two files in unix script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to attach two files in unix script
# 1  
Old 12-07-2010
How to attach two files in unix script

Hi,

My script has to send 2 files as a separate attachment(Note : files to be sent without zipping) to the specified email id.

Below code was used but it is not attaching the file as expected instead the file contents are displayed in the body of the email.

Quote:
( cat Hi; uuencode "$File1" "$File1"; uuencode "$File2" "$File2") | mail -s "attachment" abc@xyz.com
Kindly,help with your thoughts.

Thanks in Advance.
Meva
# 2  
Old 12-07-2010
If you have mutt on you system it's as easy as:

Code:
mutt -a $File1 -a $File2 -s "attachement" abc@xyz.com < Hi

# 3  
Old 12-07-2010
mutt is not available in the system Smilie

---------- Post updated at 12:34 AM ---------- Previous update was at 12:10 AM ----------

any other options please....
# 4  
Old 12-07-2010
Try if this works..uuencode your attachment files to single file and mail it..
Code:
uuencode File1 File1 > attachment_list
uuencode File2 File2 >> attachment_list

mail -s "Reports attachment" myaccount@yahoo.com < attachment_list

# 5  
Old 12-07-2010
Its not working Smilie the problem that am facing is that the files are not emailed as separate attachments but the contents of the files are displayed in the email.

---------- Post updated at 01:31 AM ---------- Previous update was at 01:10 AM ----------

my requirement is to send the files as separate attachments....in a single mail.
# 6  
Old 12-07-2010
hmm..It did work for me using the above method with multiple attachments in a single email..maybe it would take sometime to have the email in the inbox..anyway this is not the issue here. Are you sure that the attachments are appended (>>) to a single file..? Give us more input if possible.
# 7  
Old 12-07-2010
File 1
Code:
aa bb cc

File 2
Code:
aa bb cc

If the below code is used

Code:
( cat Hi; uuencode "$File1" "$File1"; uuencode "$File2" "$File2") | mail -s "attachment" abc@xyz.com

then the email body looks as given below
Quote:
Hi
aa bb cc
aa bb cc
whereas my requirement is that the files to be attached to the email and the body of email should only have the "Hi" as its text.

Kindly let me know ur thougths.
Thanks in Advance.
Meva.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Attach filename to wc results on massive number of files

Hello, I have massive number of big files that needed to be counted for the total number of lines (> 100x millions) each. I want the file name attached to the count results so that they are aligned nicely matching name and counts. I could do each file at a time, which will take hours to finish,... (8 Replies)
Discussion started by: yifangt
8 Replies

2. Shell Programming and Scripting

Script to attach latest files of directories in a mail.

Hello Folks, I am looking for the script which will go to directory and check for the latest 5 files and send a mail to attaches these files to user. Kindly guide. Regards (7 Replies)
Discussion started by: sadique.manzar
7 Replies

3. Shell Programming and Scripting

UNIX - how to send attach excel in mail

Hi Experts, i need your help here :confused: Need to send a report thru mail using unix shell script(AIX). can you help me to do this? . i tried "uuencode" with CSV format, but while reading report all values are in single column. i need each column values in separate cell. Thanks in... (9 Replies)
Discussion started by: newbieabc
9 Replies

4. Shell Programming and Scripting

How to attach multiple .csv files using mutt command

I need to attach all files starting with 'BusinessReport' using mutt command. It could be any number of files in that directory, say BusinessReport_01, BusinessReport_03, BusinessReport_04 etc. Is there a way to attach all files where filename like BusinessReport_* and sent it using mutt... (2 Replies)
Discussion started by: Jassz
2 Replies

5. Shell Programming and Scripting

Script to attach file to mail

Hello, I have a .dat file containing one line. I need a script to read that line and make it part of the body and send a mail... Let's say the line is $line. I need the script to send a mail with the body "The last disposal feed is $line". Thanks (4 Replies)
Discussion started by: sfetea
4 Replies

6. Shell Programming and Scripting

Attach a binary file to email in a script

Hi, I am trying to get an email sent out by the unix ( aix ) system that has a .gz file attached to it. I can get the attachment, but it's not working when being looked at from outlook. I think there is a problem because of the way I am doing it, and the fact that it's binary. I am trying to... (15 Replies)
Discussion started by: fwellers
15 Replies

7. Shell Programming and Scripting

attach multiple files in email

I am trying to send multiple files as attachment in one email, I tried to search but couldn't find. Please let me know if any solutions. (2 Replies)
Discussion started by: mgirinath
2 Replies

8. Shell Programming and Scripting

attach 2 files using mailx

if test.dat is the file cat test.dat|uuencode test.dat|mailx -s "subject" mailid can be used for attaching test.dat how can i attach more than one file to a mail using mailx (2 Replies)
Discussion started by: anumkoshy
2 Replies

9. UNIX for Advanced & Expert Users

pine does'nt attach files

Hello All, I am maintaining a server and I use pine as MUA and sendmail as MTA. Suddenly many users in the network face the problem of not being able to attach files using pine. I checked the sendmail.cf file and found a variable "MaxMessageSize = 1000000". Eventhough the message size... (2 Replies)
Discussion started by: maybemedic
2 Replies
Login or Register to Ask a Question