Transfering unix file as an email attachment


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Answers to Frequently Asked Questions How do I send email? Transfering unix file as an email attachment
# 1  
Old 11-15-2000
Question

I've written a a script which generates a report file, saved to a unix directory. I need to transfer it, via email, to some users. The command I'm using in my script is:
(note that subject & cur_address are set in the script prior to this line)

cat /u/sandyl/sm_o_commdt_archive/c | uuencode weekly_commiss.doc | mail -s ",subject,cur_address

The file gets emailed and attached correctly, but the problem is that the weekly_commiss.doc is 132 chars wide, so it wraps when I open it in Word. Even if I change the setup to landscape within Word, it still wraps some of the characters.

Is there any way in unix to either change the font size smaller, or some other formatting, such that when it gets emailed it will already be in the appropriate format for the user to receive it?

Thanks for your help.
# 2  
Old 11-15-2000
Sounds like your original report/file is too wide and you need to format the original report to be smaller. Changing the font size usually will not not help because the font information is not part of the flat ASCII report file.

Here are some possibilites:

(1) You must format the original report to be around 80 chars vs. the large 134 chars (maybe not what you want);

(2) You could convert the ASCII report file to another format that has formatting information, i.e. RTF, PDF, PS or some other format that has font size information and other formatting embedded in the file.

BTW: There are many kinds of freeware UNIX utilities to do this conversion. The conversion process has flags to add the formatting you need. I've even seen/used an crude ASCII to .DOC converter, but I think it was just a beta kludge.

This is an interesting question and I'm very interested to see the different approaches from other forum members. PxT, any ideas?

# 3  
Old 11-16-2000
If your input file is ascii, you can format it using nroff(1) or troff(1).
Example:

nroff /u/sandyl/sm_o_commdt_archive/c


Will format the file and display it to the screen so that both left and right margins are evenly adjusted. Of course, you can then pipe it uuencode, or whatever you need to do. nroff defaults to 6.5 inch lines, 11 inch long paper. Read the nroff or troff man pages for more info, but that example should work....let us know if not.


HTH
# 4  
Old 11-17-2000
Final resolution

Thank you both for your suggestions - they were very helpful, and eventually led me to a final solution.

Changing the original report while still in Unix was not an option - this particular report is also run by the users from a menu. My task was to get that report emailed to managers on a weekly basis, and it has to be the same report as when they run it themselves.

But I did run with your idea of changing the file type before it was transferred. I ended up using an ".wri" (Windows Write file type). Then, when the user opens their Outlook email message, they find an attached document, perfectly formatted, and they are able to use the windows scroll bars to shift view right & left to see the whole file.

Here's the resulting code line that sends the email message:
cat /u/sandyl/sm_o_commdt_archive/c | uuencode weekly_commiss.wri | mail -s ",subject,cur_address

Thanks again for your suggestions.
These 2 Users Gave Thanks to slivi For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Reading the Attachment from UNIX email

Hi - How would you read in the attachment from your unix mail account? The attachment is in BASE64 so I need to isolate those lines so I can convert them. The number of lines varies from a few to a few hundred. To complicate matters, the mail box gets non related emails I want to ignore. The lines... (3 Replies)
Discussion started by: Oliver Burns
3 Replies

2. Shell Programming and Scripting

Email with attachment from local machine through UNIX

Hello everyone, So, here is my requirement. I want to run an SQL query and export the result in an excel file and send that as an attachement in an email to the intended receipients. Please help me understand how to do that. How to connect to database, how to export the output in an excel... (3 Replies)
Discussion started by: Mohdrafi12
3 Replies

3. Shell Programming and Scripting

html format email with attachment in unix

Team, I have the below code, which is working fine and it sends the html report using sendmail command. I want to attach one more file ( which goes as attachment ) in that email. How to achieve it. i tried with uuencode. But no luck :mad: outputFile="/tmp/out.html" ( echo... (2 Replies)
Discussion started by: itkamaraj
2 Replies

4. Shell Programming and Scripting

UNIX file attachment in email

Hi, I have a syntax for mail attachment as $EMAIL "Wrapper $wrapper_script_name has failed" " $wrapper_script_name has Failed " $failed_email_address and $EMAIL is as below MSGSub=${1} MSGText=${2} RMAIL=${3} #set LANG='' export LANG='' echo "${MSGSub}" | mailx -s "${MSGText}" ... (1 Reply)
Discussion started by: satgur
1 Replies

5. AIX

Send email from unix (AIX) with PDF attachment

I am using the following command to send PDF attachment with a mail. uuencode <attachment.pdf> <attachment.pdf>|mailx -s <subject> <mail_id> < <Message_file.txt> This one send the message with attachment. I would like send PDF attachment with the mail Can any one help with this issue ? ... (0 Replies)
Discussion started by: sunjup
0 Replies

6. Shell Programming and Scripting

Send email with attachment in form of excel in unix

Hi, I have a shell script which send email with an attachment in the form of an email. However, the when I open the attachment, all the data comes in one column. How do I format the data in the excel sheet while sending the email? Thanks (8 Replies)
Discussion started by: bdebroy
8 Replies

7. Shell Programming and Scripting

send email from unix with attachment

Hello All, This is a common question that I found lot of results in the forums. I am trying to use uuencode to attach a file and send email. I have no issues sending email, but not able to attach any files using sendmail. Is uuencode part of sendmail or does 'uuencode' utility need to be... (1 Reply)
Discussion started by: chiru_h
1 Replies

8. UNIX for Dummies Questions & Answers

unix to Lotus Notes email attachment

Hi all, I have searched the FAQ and find that there is some threads related to this subject. But can you please give an examples on how to send attachment to Lotus Notes email through UNIX? Since i have gone through the RFC and the URL. But i still have no idea on it. Please give some... (7 Replies)
Discussion started by: wilsonchan1000
7 Replies

9. UNIX for Dummies Questions & Answers

unix to Lotus Notes email attachment

We have been trying to get an email from unix to Lotus Notes to work. We finally got it to work with the following code: cat filename | uuencode filename | mailx -s "subject title" email address Now our problem is that Lotus Notes doesn't show the paper clip icon, indicating an attachment... (3 Replies)
Discussion started by: cowgilm
3 Replies

10. UNIX for Dummies Questions & Answers

Transfering unix file as an email attachment

I've written a a script which generates a report file, saved to a unix directory. I need to transfer it, via email, to some users. The command I'm using in my script is: (note that subject & cur_address are set in the script prior to this line) cat /u/sandyl/sm_o_commdt_archive/c | uuencode... (3 Replies)
Discussion started by: slivi
3 Replies
Login or Register to Ask a Question