Excel attachment in e-mail


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Excel attachment in e-mail
# 1  
Old 07-24-2008
Excel attachment in e-mail

Hi,

I have to send the query output as an excel attachmet from UNIX Shell script, for this i have written following shell script and sql file this shell script has created the ho.xls file with correct query output but it doesn't generate the mail that shold contain query output as an excel attachment, could anyone please tell me the correct script for my requirement.

Will the script generate the log file as an excel file?

I am using Sun OS 5.6 and Oracle 8i

ho.sh
------

#!/bin/csh
setenv ORACLE_HOME /opt/app/oracle/product/8.1.7
setenv ORACLE_SID environ
set BINARIES=/usr/bin
set APPDIR=/u08/Temp
$ORACLE_HOME/bin/sqlplus uname/pwd @$APPDIR/ho.sql > $APPDIR/ho.xls
uuencode $APPDIR/ho.xls $APPDIR/ho.xls | /usr/bin/mailx -s "Attachment" karthikeyanjo@hcl.in

ho.sql
------
set lines 200
set pagesize 100
select to_char(transaction_date,'HH24')||':00 - '||to_char(transaction_date,'HH24')||':59' "Hour",
count(*) "Total_Hits"
from adsl_interface_log_cng
where trunc(transaction_date)=trunc(sysdate-1)
AND (decode(TRANSLATE(UPPER (adsl_ra_reasoncode),'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!"##$%^&*()-_=+[{]}@;:#~,<.>/?`?/'' ','1234567890'),0,NULL,
TRANSLATE(UPPER (adsl_ra_reasoncode),'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!"##$%^&*()-_=+[{]}@;:#~,<.>/?`?/'' ','1234567890'))
/10) < 2
group by to_char(transaction_date,'HH24')
order by to_char(transaction_date,'HH24');
# 2  
Old 07-24-2008
Question Does it give an error?

I do not see anything wrong in syntax with your command.

a) can you manually ftp the .xls file to your pc and verify it as good?
b) instead of uuencode the .xls, can you try and send the ho.sh file?

The answer to these two questions should start the error-correction process.
# 3  
Old 07-25-2008
Excel attachment in e-mail

Hi,

Is it possible to generate an excel file by UNIX Shell script?

I have modify the ho.sh script as follows and i have made spool file in sql file as spool /u08/Temp/ho.txt

ho.sh
------

#!/bin/csh
#!/bin/bash
#!/bin/ksh
setenv ORACLE_HOME /opt/app/oracle/product/8.1.7
setenv ORACLE_SID riker
set BINARIES=/usr/bin
set APPDIR=/u08/Temp
$ORACLE_HOME/bin/sqlplus adsl_stats/adsl_stats01 @$APPDIR/ho.sql
uuencode $APPDIR/ho.txt $APPDIR/ho.txt | mailx -s "Attachment" mail@com

The above script generate the mail with text file that conatins the query output as an attachment in crontab but while ftping the file it shows permission denied( i hve given chmod 777 to this file).

Could you please tell me any command or script that should convert the text file into an excel file in UNIX, i nedd to schedule it in crontab with mail generation option.

Thanks in advance
# 4  
Old 07-25-2008
Hammer & Screwdriver Excel file from unix

Two methods for this:
(a) There are specific add-ons you can obtain that allow fairly extensive use of Excel commands and functions to be created by a unix shell.
or...
(b) Create a .csv file. Excel can open (and write) .csv files. So, you could build a file along the following idea. Please note is is not complete code, but a sample of some of the commands to use. [I do many of these in my job - creating reports others can read in Excel.]

Code:
csv_f="my_excel.csv"
echo "John Doe","12 Main Street Boston MA",100,10 >>$csv_f
echo "Karthi Key","52 Commercial Way New York NY",200,5 >>$csv_f
uuencode "$csv_f" "$csv_f" | mailx -s "important excel" karth@anywhere.com

# 5  
Old 07-25-2008
Excel attachment in e-mail

Hi,

Thank you for your reply

Finally i got the correct output with following scripts

ho.sh
------

#!/bin/csh
#!/bin/bash
#!/bin/ksh
setenv ORACLE_HOME /opt/app/oracle/product/8.1.7
setenv ORACLE_SID riker
set BINARIES=/usr/bin
set APPDIR=/u08/Temp
$ORACLE_HOME/bin/sqlplus adsl_stats/adsl_stats01 @$APPDIR/ho.sql > ho.xls
uuencode ho.xls ho.xls | mailx -s "Attachment" karthikeyanjo@hcl.in

ho.sql
------
set feedback off
set echo off
set pagesize 100
select to_char(transaction_date,'HH24')||':00 - '||to_char(transaction_date,'HH24')||':59' "Hour",
count(*) "Total_Hits"
from adsl_interface_log_cng
where trunc(transaction_date)=trunc(sysdate-1)
AND (decode(TRANSLATE(UPPER (adsl_ra_reasoncode),'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!"##$%^&*()-_=+[{]}@;:#~,<.>/?`?/'' ','1234567890'),0,NULL,
TRANSLATE(UPPER (adsl_ra_reasoncode),'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!"##$%^&*()-_=+[{]}@;:#~,<.>/?`?/'' ','1234567890'))
/10) < 2
group by to_char(transaction_date,'HH24')
order by to_char(transaction_date,'HH24');

If i create the spool file in sql script as ho.xls also gave the output but the output is combined in single column and the spool file size is more compare to above one.
# 6  
Old 08-12-2008
uuencode

Hi,

Can u send me the script/command you have used.

Regards,
Karthik
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sending Excel Files as attachment using Mail

Hie, I need to attach an .xlsx file as an attachment to a mail. I have used the mail option but i dont think there is anything for attachment. Can you show me how else can i do it? I am not allowed to install mutt since it is a workplace and they have their restrictions. And its a Bash Shell (2 Replies)
Discussion started by: barryallen
2 Replies

2. UNIX for Beginners Questions & Answers

Excel attachment in e-mail

i am trying to get an SQL output into an excel attachment and the other output into mail body as excel format. i am getting the excel format in the mail body, but i am not getting the excel attachment. and the output is coming in one cell in the excel. is it possible to get the excel output with... (11 Replies)
Discussion started by: maddelav
11 Replies

3. Shell Programming and Scripting

Excel file attachment showing data in single column

Hi All, found similar posts, but not exatcly what i wanted. I have an text file like below and am trying to send mail as an excel file but when i get the excel file as the attachment, all the data is coming in the first column. I need below data in 4 columns. Unix file Name,ID,Trade,Date... (3 Replies)
Discussion started by: robinbannis
3 Replies

4. Shell Programming and Scripting

mailx not sending excel attachment properly

Hi, I am trying to send email with attachment using mailx command. I am using the folowing command: uuencode XX_HWSW_BUYERWISE_88963631_1.xls XX_HWSW_BUYERWISE_88963631_1.xls | mailx -s "Test Mail as Attachment" oracleams@xyz.com I get the email in the inbox. However, when I try to open the... (5 Replies)
Discussion started by: asp_julius
5 Replies

5. Shell Programming and Scripting

MIME - HTML mail with Excel attachment - Please help!

#!/bin/ksh ( echo "MIME-Version: 1.0" echo "Content-Type: multipart/mixed; boundary=frontier" echo "--frontier" echo "Content-Type: text/html" echo "Content-Disposition: inline" echo "\n" echo "<html><body><h1>this is html formatted text</h1></body></html>" echo "--frontier" echo... (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

6. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

7. Shell Programming and Scripting

Mail attachment with unix mail

Hi Could someone help me with the details on how to send an attachment through mail in unix. I have an html file in my unix machine and I want this to be send to some mail id, plese help with the steps. Regards Ajay (2 Replies)
Discussion started by: ajaykumarboyana
2 Replies

8. UNIX for Advanced & Expert Users

mailx commannd - Mail and Attachment in same mail

Hi , I am using mailx command for sending the mails. Rightnow I am sending the attachment (by using uuencode $filename) as a seperate mail.I wanna send the attachment also with the same mail. (6 Replies)
Discussion started by: sharif
6 Replies

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

10. UNIX for Dummies Questions & Answers

mail attachment

This question has been asked many time before. I did search other questions. But was not able to work out. Really sorry for repeating the same question. I have mail and mailx and sendmail installed. It Tried this uuencode FILENAME.txt FILENAME.txt | mail mymail@yahoo.com the attachment... (3 Replies)
Discussion started by: sushrut
3 Replies
Login or Register to Ask a Question