UNIX attachement email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX attachement email
# 1  
Old 08-03-2016
UNIX attachement email

I am having an issue sending a text file as an attachment. It is an oracle sql report generated as text. The file is formatted fine. However, when it is emailed and opened in notepad it is missing new lines and not not formatted properly. It is on solaris 10. Here is my code:
Code:
 #! /bin/ksh
host=`uname -n`
rptFile="/user_files/monitor/data/chkdbSpace.txt"
Emailist="myemail@dom.com\
"
sqlplus -s id/passwd << -
clear columns
column tablespace format a25
column total_mb format 999,999,999.99
column used_mb format 999,999,999,999.99
column free_mb format 999,999,999.99
column pct_used format 999.99
column graph format a25 heading "GRAPH (X=5%)"
column status format a10
compute sum of total_mb on report
compute sum of used_mb on report
compute sum of free_mb on report
break on report
SET WRAP OFF
SET FEEDBACK OFF
SET ECHO OFF
SET LINESIZE 130
SET PAGESIZE 50
SPOOL $rptFile
select total.ts tablespace,
DECODE(total.mb,null,'OFFLINE',dbat.status) status,
total.mb total_mb,
NVL(total.mb - free.mb,total.mb) used_mb,
NVL(free.mb,0) free_mb,
DECODE(total.mb,NULL,0,NVL(ROUND((total.mb - free.mb)/(total.mb)*100,2),100)) pct_used
from
(select tablespace_name ts, sum(bytes)/1024/1024 mb from dba_data_files group by tablespace_name) total,
(select tablespace_name ts, sum(bytes)/1024/1024 mb from dba_free_space group by tablespace_name) free,
dba_tablespaces dbat
where total.ts=free.ts(+) and
total.ts=dbat.tablespace_name
UNION ALL
select sh.tablespace_name,
'TEMP',
SUM(sh.bytes_used+sh.bytes_free)/1024/1024 total_mb,
SUM(sh.bytes_used)/1024/1024 used_mb,
SUM(sh.bytes_free)/1024/1024 free_mb,
ROUND(SUM(sh.bytes_used)/SUM(sh.bytes_used+sh.bytes_free)*100,2) pct_used
FROM v\$temp_space_header sh
GROUP BY tablespace_name
order by 6
/
SPOOL OFF
ttitle off
rem clear columns
-
###As an attachment in Solaris:
( echo 'see attached file';uuencode /user_files/monitor/data/chkdbSpace.txt chkdbSpace.txt ) | mailx -s "$host SMG DB Space Report" "$Emailist"
exit 0

The file is formatted as follows:

Code:
TABLESPACE STATUS TOTAL_MB USED_MB FREE_MB PCT_USED
------------------------- ---------- --------------- ------------------- --------------- --------
WNP_201410_IDX_TS ONLINE 2,700.00 1.00 2,699.00 .04
WNP_201409_IDX_TS ONLINE 2,350.00 1.00 2,349.00 .04

....etc

But when emailed:

Code:
TABLESPACE STATUS TOTAL_MB USED_MB FREE_MB PCT_USED 
------------------------- ---------- --------------- ------------------- --------------- -------- 
WNP_201410_IDX_TS ONLINE 2,700.00 1.00 2,699.00 .04 WNP_201409_IDX_TS ONLINE 2,350.00 1.00 2,349.00 .04 WNP_201408_IDX_TS ONLINE 2,100.00 1.00 2,099.00 .05

Moderator's Comments:
Mod Comment Please use CODE tags for sample input and sample output as well as for code segments.

Last edited by Don Cragun; 08-03-2016 at 03:37 PM.. Reason: Add missing CODE tags.
# 2  
Old 08-03-2016
Because you are sending a file with only newline termination instead of carriage-return, newline.
Use unix2dos or add "\r" to the end of each line in the original file.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

VIP Membership - The UNIX and Linux Forums - Get Your UNIX.COM Email Address Here

We work hard to make The UNIX and Linux Forums one of the best UNIX and Linux knowledge sources on the net. The site is certainly one of the top UNIX and Linux Q&A sites on the web. In order to provide certain members the best quality account services, you can now get some great extra features by... (2 Replies)
Discussion started by: Neo
2 Replies

2. Shell Programming and Scripting

sending attachement in mail

Hi , I am using the below code to send mail through a script which run as a cron job. msgdate=`date +"%a, %e %Y %T %z"` daemail=$(cat <<! From: $from To: $emailtarget Subject: $subject Mime-Version: 1.0 Content-Type: multipart/mixed; Content-Disposition: inline $priority $CONTENT !)... (2 Replies)
Discussion started by: ahamed
2 Replies

3. Shell Programming and Scripting

attachement through mail command

Can't attach text files to 'mail' command. I dont have mutt or mailx to use on my server. so i have to use mail command any help would be great. Regards, Kiran (1 Reply)
Discussion started by: dddkiran
1 Replies

4. UNIX for Advanced & Expert Users

How to read mail attachement

I want to read attachements sent to unix mail id and save the attachement in folder. I may receive the mails from different mail clients(outlook, lotus ..etc). Attachements are in CSV(comma saperate) format. Let me know the shell script code for this. Regards, Venkat (1 Reply)
Discussion started by: svenkatareddy
1 Replies

5. Shell Programming and Scripting

Email sending attachement with two file comparision

Hi guys, I have two files . One file contains log record and another file contains emailids which is supposed to send it users File1 : Name : abc_xyz_data.txt Which contains log record File 2 : Name : abc_xyz_mailids.txt Which contains emailids. abc@test.com bcd@test.com I... (4 Replies)
Discussion started by: orabalu
4 Replies

6. Shell Programming and Scripting

query about Attachement in mail

Hi All, I have general query that ...in my script i used uuencode option like below. cd /location (cat test.txt uuencode test.csv test.csv ) | mail -s "test mail" "mail_id" but whenever i run the above command its giving error like below ./testscript.sh: uuencode not found: ... (1 Reply)
Discussion started by: Shahul
1 Replies

7. UNIX for Dummies Questions & Answers

Send email with attachement-Getting connection refused by domain

Hi all, I am a newbie to unix. I need to send an email with an attachment in unix to some id like abc@some_company.com Code i have used is ------------Code--------------------------- #!/bin/ksh set -x #set -n #cript: unix_mail_withattachments.ksh # Aurthor: Ravin Maharaj #... (1 Reply)
Discussion started by: samuelc
1 Replies

8. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

9. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question