uuencode problem

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users uuencode problem
# 1  
Old 07-08-2011
uuencode problem

I am making a shell script on HP-UX that will do some Oracle db query and fetch data. Then after formatting the output files (there are two files) in a csv format, I want to send them as email attachments. Unfortunately the email contains garbage. I could not find solution to the problem on forums. Can anyone help me ? Part of the code is below.
1_OUT="${WORKDIR}/1.`date +%Y%m%d`.csv"
2_OUT="${WORKDIR}/2.`date +%Y%m%d`.csv"
( uuencode ${1_OUT} ${1_OUT};uuencode ${2_OUT} ${2_OUT} ) | mailx -s "Attachments are in standard format" <emailid>

I am receiving the email im mS Outlook but it contains junk data in mailbody with no attachment.
Mail bode contents (first two lines) are:
begin 640 /home/asutoshch/1.20110707.csv

Thank you.
# 2  
Old 07-08-2011
You are just dumping the two uuencoded files into the body with no indication that they are attachments, so I would expect that the mail you receive at the destination is just the uuencoded files.

I did a couple of rounds of quick tests here (SuSE Linux) and this seems to do what you want:

echo "There should be attachments" | mail  -s "subject" -a file1.csv -a file2.csv user@system.com

The -a option attaches file 1 and file 2 rather than putting them into the body. Unless your destination knows how to deal with a uuencoded file, you will still have issues if you attach the uuencoded files. If you were uuencoding to "get them through the mail," then the attachment option should do any necessary encoding (quoted printable or base64 if the data is binary) and the mail reader at the other end should know how to deal with either of those two encoding types. Thus, I think the files that you need to supply on the command line are the names of the original .csv files.

Note that I used mail and not mailx; mailx on my system didn't support -a. You might want to read the man page for both mail and mailx.

Hope this gets you further along.
# 3  
Old 07-09-2011
Thank you, but mail is not working for attachment on HP-UX. I could not get from man page.
# 4  
Old 07-09-2011
On HP-UX, neither mail nor mailx handle the creation of attachments. The best you can do is to uuencode the files and embed them in the body of the message.
# 5  
Old 07-09-2011
Hi Murphy,
Thanks for your response. but I have seen several excel reports coming as email attachment daily from shell program on HP-UX box. So I was thinking if I can implement that.
# 6  
Old 07-10-2011
HP_UX does not natively support Excel. Some application is programatically writing files in Excel format and mailing them as attachments. That is perfectly do-able. For example, there are Perl modules that will convert data to Excel format and mail files as attachments.
# 7  
Old 07-10-2011
Keeping it all simple, however...you might want to note that even Excel doesn't need things to be all that smart unless it's expecting specific formatting in the attachment. The Perl Excel modules are tremendous, but if you're only expecting to send text dumps, and not formatted content, Excel can take a tab-delimited file with a .xls (or similar, registry-based) extension.

On Windows, Excel is invoked according to the file extension in use...and tab-delimited is the default, so it just works. (Pardon the pun...)

Use uuencode to embed the attachments into your mail, and you've achieved the same results as your system's other shell script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with uuencode

Hi, I am trying to send an attachment through UNIX to the mail box. But along with the attachments I am also receiving junk data as a text file, Suppose "Hi" is the subject of the mailx command then along with the attachment I am getting Hi.txt also. Below are the commands which I used : - ... (15 Replies)
Discussion started by: Alex_Smith
15 Replies

2. Shell Programming and Scripting

mailx, uuencode problem

I've this command to run ... Purpose : Send attachment file with e-mail body... ( E-mail body i read it from text file) uuencode TEST_FILE.csv TEST_FILE.csv | cat /usr/local/bin/EMAIL_BODY.txt - | mailx -s "TEST Report" -c receiver1@mail.com receiver2@mail.com Here is the... (2 Replies)
Discussion started by: prash184u
2 Replies

3. Shell Programming and Scripting

problem with uuencode

Hi everyone, I'm emailing a spool file to a person using mailx. I'm using uuencode to attach the file to the email. but am getting this error uuencode: ISO8859-15 to 646 conversion: Invalid argument Any ideas as to why. The code is below sqlplus -s user/password@database <<EOF set... (9 Replies)
Discussion started by: rjsha1
9 Replies

4. Shell Programming and Scripting

Problem with uuencode

i used below code to attach a file but it's not attaching the file but sendinf a simple mail uuencode ${discord_file} mail_list.txt | mailx -s "TEST MAIL" xxx@yahoo.com (3 Replies)
Discussion started by: punitpa
3 Replies

5. Shell Programming and Scripting


Hi All, I have a queryin the uuencode option. Actually i need to attach two files in a single mail. I am aware of attaching a single file using the command below. (echo " The first file ";uuencode file1 file1) | mailx -s " The files " venkidhadha@in.com However i am not sure what... (6 Replies)
Discussion started by: venkidhadha
6 Replies

6. UNIX Desktop Questions & Answers

uuencode for attachment giving problem

Hi All, I am using unix's sendmail utility to send mails with attacments. I am using the uuencode command for attachments (zip). When i send the mails to some account which is configured in the MS outook it opens/unzip the attachments with no problem. But the same attachments seems to be... (3 Replies)
Discussion started by: manojram
3 Replies

7. Solaris

uuencode and mailx problem

We are running solaris 9. I can send emails using mailx with no problems. I can send attachments using uuencode no problems. What I can't do is change the name to .txt or .doc or anything else using uuencode. The command I am using is: uuencode /tmp/AsetReports /tmp/AsetReports.doc | mailx -s... (2 Replies)
Discussion started by: zeekstern
2 Replies

8. Shell Programming and Scripting

Problem with uuencode

I a script i telnet port 25 and part of the attachment is echo "Content-type: application/msword; filename= "$3" " echo Content-transfer-encoding: base64 echo "Content-disposition: attachment; filename= "$3" " echo uuencode -m "$3" /dev/stdout $3 is a word document. When i send... (0 Replies)
Discussion started by: markms
0 Replies

9. UNIX for Dummies Questions & Answers

Uuencode problem in mail attachment

I have a unix script that compresses a .txt file using gzip command and then sends it by mail using uuencode. This has been working fine for some time, but lately I've been experiencing some problems, as when I open the mail generated, I don't see the attachment, but instead I get a large amount... (8 Replies)
Discussion started by: mvalonso
8 Replies

10. Shell Programming and Scripting


hi all, I dont know of this is a duplicate thread, but the thread i started a while ago wasnot posted still. ok my question is i have a shell script named "mail_editck.sh". i have to include some reports in it so that i can get the email when they are done. the syntax goes like this. ... (2 Replies)
Discussion started by: tejasingaraju17
2 Replies
Login or Register to Ask a Question