Unable to use mimesender to send attachments with spaces in the file names / paths


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unable to use mimesender to send attachments with spaces in the file names / paths
# 1  
Old 03-04-2009
Unable to use mimesender to send attachments with spaces in the file names / paths

Hello,
I found the mimesender multiple attachment emailing shell script in the FAQ of these forums, and I have been able to use it to send multiple files, but only if they don't have spaces in their file name or path.

When I attempt to send a file with spaces in it's name, enclosed within quotations such as -A "/Invoices/ABC DEF.pdf" , I get the errors:
cat: /Invoices/ABC: No such file or director,
cat: DEF.pdf: No such file or directory

Where each word in the file name, which had been separated by spaces, is being looked at as a separate file, instead of as one file.

This is odd, considereing I can run cat "/Invoices/ABC DEF.pdf", without any problem, from the command prompt.


I'm also unable use spaces in the name that the file willl be sent as. If I send it using the option -D "Real filename which the recipient will receive.txt", I get the error: uuencode: cannot open file Real : No such file or directory (error 2). This also appears to be a mimesender issue, since, if I can uuencode a file with spaces in it's name from the command prompt, as long as it's enclosed withing quotations.


Is the problem that the arrays ATTACH and DESC array elements cannot hold a quoted string? The SUBJECT variable is set the same way as the ATTACH and DESC are, yet it can hold a quoted string of words: SUBJECT=$OPTARG, ATTACH[nattach]=$OPTARG, DESC[nattach]=$OPTARG.


Emails sent directly using unix mail and uuencode can send one (non-MIME-compliant) attachment, even if the source file has spaces in it's path/name, or if the renamed file has spaces in it:
uuencode "/Invoices/ABC DEF.pdf" "ABC DEF.pdf" | mail -s "test" rsmorra@amco.ws


I thought that mimesender's problem with spaces might have been due to the quotes already surrounding the file names in the MIME header construction section of mimesender:
scribe_out 'Content-Type: '${TYPE}'; name="'${ATTACH[i]}\"
scribe_out 'Content-Disposition: attachment; filename="'${DESC[i]}\"
I imagine this could be fixed by only adding the quotes conditionally, if the ATTACH[i] and DESC[i] don't already begin and end with them.

After the code that makes the MIME header is fixed to only have one set of quotes surrounding a file name, whether or not there are with spaces in the file name, it seems that mimesender would still break apart the original file name before it sends it cat, and break up the -D "file name as sent.ext" before running it through uuencode.

Any ideas how I can prevent mimesender from breaking apart of the original "/path/and file name", and the "Send as this file name.ext" before they reach cat and uuencode? Thanks a lot.

p.s. Please see a copy of the mimesender script in the attached .txt file.

p.p.s. The actual script does not have a .txt file extension, but that was needed to attach it here. The original script can be seen at the link above. I already tried contacting it's author, and am awaiting reply.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with reading directory paths with spaces from a file

Hi I want to know how to handle the spaces in the below scenario. I have a file (CON_zip_path_1.txt) which has some directory paths with spaces in directory names . My requirement is to unzip these zip files to another path. Please see the code below and the error. CON_zip_path_1.txt... (4 Replies)
Discussion started by: paul1234
4 Replies

2. OS X (Apple)

Remove leading spaces from file names and folders

Hi All, I have a vexing issue with leading spaces in file names. Basically, we're moving tons of data from our ancient afp file share to Box.com and Box forbids leading spaces in files or folders. The HFS file system seems to be perfectly fine with this, but almost all other Unix file systems... (1 Reply)
Discussion started by: prometheon123
1 Replies

3. OS X (Apple)

File paths with spaces in a variable

Hi all my very first post so go easy on me!! I am trying to build a very simple script to list a file path with spaces in. But I can't get around this problem. My script is as follows: #!/bin/bash X="/Library/Users/Application\ Support/" LS="ls" AL="-al" $LS $AL $X The response I... (5 Replies)
Discussion started by: tillett22
5 Replies

4. Shell Programming and Scripting

Remove spaces from start of file names

Hi, I have a directory with the following file names 01 - abc hyn 02-def 03-ghi.dir 04 - jhu.dir abc1 kil def bil The last two file names abc1 starts with one space and def starts with double space. I want these files in my directory to be renamed as ABC HYN DEF GHI.dir... (6 Replies)
Discussion started by: jacobs.smith
6 Replies

5. Shell Programming and Scripting

How to strip the spaces in file names?

please somebody tell me what is wrong with this, while the thumbnail grabbing works and encoding works, but what is not working is, mv $i.jpg /var/www/thumbs/ and mv $i.mp4 /var/www/uploads/ #!/bin/bash # MINT 9 - FFMPEG - QT-FASTSTART - X264 - MP4 DIR=/var/www/tmp for i in... (9 Replies)
Discussion started by: mysoogal
9 Replies

6. Shell Programming and Scripting

Find Directory from array of file names with paths

I have a script that generates a variable with the location of a file and its complete path. What i want to do is to "cd" to the directory where that file is located using the path name of the file. GIS has absolutely failed me. For example when i run my script it generates a variable called... (1 Reply)
Discussion started by: Knome
1 Replies

7. UNIX for Advanced & Expert Users

send attachments using send mail in Solaris

Hi All, I have a requirement to send and email of body html with an attachment. concatinating uuencode output to the mail body with mailx command works, but as my Email body is of HTML type i use sendmail. my command to send HTML body is as below: export MAILTO="recipient@domain.com"... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

8. Shell Programming and Scripting

Remove spaces between file names

Hi All, I have spaces in between file names. "Material Header.txt" "Customer Header.txt" "Vendor Header.txt" And how can I remove spaces between file names like below MaterialHeader.txt CustomerHeader.txt VendorHeader.txt Thanks Srimitta (10 Replies)
Discussion started by: srimitta
10 Replies

9. Shell Programming and Scripting

File names with spaces? Is it possible?

Gurus - I got one simple TXT file with long file name with blank spaces in between the words. I am trying to display that full file name, but it breaks while displaying. Could somebody shed some light here? Script ------ for i in `cat ~\temp\employee.txt` do echo $i done (5 Replies)
Discussion started by: Eric_2005
5 Replies
Login or Register to Ask a Question