Multiple attachments using mutt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple attachments using mutt
# 8  
Old 02-06-2013
Here attachment files are being read from REPORTS.LOG which has got file names as :

/home/jboss/temp/a.html
/home/jboss/temp/temp/b.html

Here files are separated by new line character "\n".

Hence we can change IFS to "\n" instead of default " " before files names are appended around -a inside the for loop

Code:
IFS_backup=$IFS
IFS=$'\n'
for (( i=0; i<$TOTAL_REPORTS; i++ ))
do
        a[i]=`sed -n "$((i+1))""p" "REPORTS.LOG"`
        attachments=( "${attachments[@]}" "`echo "-a ${a[i]} "`")
done
IFS=$IFS_backup

---------- Post updated 02-06-13 at 12:21 PM ---------- Previous update was 02-05-13 at 06:08 PM ----------

Issue found.
We know default IFS for bash shell is " " [[SPACE].
Hence while above script tries to read the attachments, for some reason string is broken.
So we can update script to set temperory IFS to "\n" while the attachment files are being read in a for loop and then set original IFS state.
Code:
TEMP_IFS=$IFS
IFS=$'\n'
for (( i=0; i<$TOTAL_REPORTS; i++ ))
do
        a[i]=`sed -n "$((i+1))""p" "REPORTS.LOG"`
        attachments=( "${attachments[@]}" "`echo "-a ${a[i]} "`")
done
IFS=$TEMP_IFS

This is tested and works as expected.
# 9  
Old 02-07-2013
If you set IFS just in a subshell, when then subshell is gone, so is the funny IFS.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Email Using uuenview w/ Multiple Attachments

HP-UX mbhp7640 B.11.31 U ia64 4294967295 unlimited-user license Our database builds a MIME compliant html email, then cats that to sendmail - no problem. Due to horrible issues with the native uuencode, we long ago began using uuenview to encode our attachments - no problem. An example is... (1 Reply)
Discussion started by: bubba77
1 Replies

2. Shell Programming and Scripting

Attach multiple index.html file using mutt

Hi I want to attach multiple index.html, index_v2 file using mutt command basically i want first index.html and then index_v2.html file as a body in email , these html files are test reports I am using following command , but it is over writing , any help appreceated ;) mutt -e... (2 Replies)
Discussion started by: madankumar.t@hp
2 Replies

3. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

4. Shell Programming and Scripting

How to send email with multiple attachments ?

Hello , I am trying to send an email with two attachments . I have tried all previous suggestion in this forum but none worked. I could send one attachment in an email by uuencode $file "$file" | mailx -m -s "File" xxx@xx.com but unable to send multiple attachments . I have tried ... (8 Replies)
Discussion started by: RaviTej
8 Replies

5. UNIX and Linux Applications

Attachments in MUTT.

Can any body figure out how to attach the attachments mails while drafting them in MUTT form any location on my system. I am not able to figure it out. (0 Replies)
Discussion started by: nixhead
0 Replies

6. 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

7. Shell Programming and Scripting

E-mailing Multiple Attachments in AIX

Hello Everyone, I'm trying to write ascript on AIX 5.3, that will e-mail all filles within a directory. But on executing a script , it sends only 1 file from the directory alongwith some Junk data. I have searched whole forum and almost used all the suggestions, but still getting same problem.... (4 Replies)
Discussion started by: Gem_In_I
4 Replies

8. Shell Programming and Scripting

Sending multiple attachments

Hi people, I am new to this forums. I have a quick question I hope one of you could help me with. I am writing a script to send attachments via email. However I am having trouble when trying to send multiple attachments. Here is the code I am using: send_mail() { uuencode $TMP $TMP1 > $TMP1... (1 Reply)
Discussion started by: deo2k8
1 Replies

9. Answers to Frequently Asked Questions

multiple attachments

how can you send multiple attachments in 1 email, usually I just use uuencode to send 1 attachment. thanks (5 Replies)
Discussion started by: edog
5 Replies

10. How do I send email?

multiple attachments

how can you send multiple attachments in 1 email, usually I just use uuencode to send 1 attachment. thanks (5 Replies)
Discussion started by: edog
5 Replies
Login or Register to Ask a Question