Mail a formatted csv file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mail a formatted csv file
# 1  
Old 02-21-2014
Mail a formatted csv file

I have the below script
i am getting the csv in garbled format.Please suggest the changes.
SUNOS

Code:


#######################################################################
####MAIN SCRIPT
#######################################################################
today=`date "+%m-%d-%Y  %H:%M:%S"`; export today
CUR_DIR=/arbor/fx1/rraj; export CUR_DIR
SCRIPT_DIR=/arbor/fx1/rraj
LOG_FILE=$CUR_DIR/error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo

### Connecting to ORACLE DATABASE

echo "SQLPLUS CONNECTION"

sqlplus -s $USR/$ASSWD@$OID<<EOF>$CUR_DIR/sql_output.csv
set feedback off
set heading off
select 
'"' ||area_code ||'"' as area_code,
'"' ||phone_number ||'"' as phone_number,
'"' ||customer_name ||'"' as customer_name,
 '"' ||address1 ||'"' as address1,
'"' ||address2 ||'"' as address2,
'"' ||city ||'"' as city,
'"' ||zip ||'"' as zip,
'"' ||CREATE_DATE ||'"' as CREATE_DATE
from 
t
EOF
if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi






cat <<EOF | ( cat -; uuencode  /arbor/fx1/rraj/sql_output.csv sql_output.csv ) | mailx -s "Activity Log" s@s.com
Hello !!!

How are you?PFA for the file.

Regards
Rahul
EOF


Last edited by rafa_fed2; 02-21-2014 at 06:09 AM..
# 2  
Old 02-21-2014
Looks like your script is incomplete where is one more EOF ? it should be before if [ $? -eq 0 ]; then
# 3  
Old 02-21-2014
Quote:
Originally Posted by Akshay Hegde
Looks like your script is incomplete where is one more EOF ? it should be before if [ $? -eq 0 ]; then
yes but thats not an issue.

can you just tell me how to send proper formatted csv file to email
# 4  
Old 02-21-2014
Please show us WHAT is garbled. Post your output file.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Required formatted output on mail for disk utilization

Hi Experts, Could you pls help with below query I have written below script to capture disk utilization and then send the output on mail. But getting unformated output on mail #!/bin/bash echo "Hi Sur,">dfoutput.csv printf '\n' >>dfoutput.csv echo "Please find BAYSQUAR2 filesystem... (4 Replies)
Discussion started by: as7951
4 Replies

2. Shell Programming and Scripting

Save output of updated csv file as csv file itself, part 2

Hi, I have another problem. I want to sort another csv file by the first field. result.csv SourceFile,Airspeed,GPSLatitude,GPSLongitude,Temperature,Pressure,Altitude,Roll,Pitch,Yaw /home/intannf/foto5/2015_0313_090651_219.JPG,0.,-7.77223,110.37310,30.75,996.46,148.75,180.94,182.00,63.92 ... (2 Replies)
Discussion started by: refrain
2 Replies

3. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

4. UNIX for Advanced & Expert Users

Mail csv as xls in shell

Hello, I have one csv file(";" separated). I would like to mail it as an attachment in xls format. I tried it using below command but its coming in one column. I wan to have different columns as per delimiter ";". unix2dos FILENAME | uuencode FILENAME FILENAME.xls | mailx -s "Hi" mailid... (3 Replies)
Discussion started by: skhichi
3 Replies

5. Shell Programming and Scripting

Mail csv to xls in Shell Script

Hello, I have one csv file(";" separated). I would like to mail it as an attachment in xls format. I tried it using below command but its coming in one column. I wan to have different columns as per delimiter ";". unix2dos FILENAME | uuencode FILENAME FILENAME.xls | mailx -s "Hi" mailid... (1 Reply)
Discussion started by: skhichi
1 Replies

6. Shell Programming and Scripting

mail a csv file as an excel sheet!

Hi, The result of a script is a csv file in the following format: cat $file_name DATA_USAGE_FACT,YES_NO_FLG,TARGET_TABLE,YES_NO_FLG,1,0,15,0 DATA_USAGE_FACT,DATE_OF_CREATION,TARGET_TABLE,DATE_OF_CREATION,29,9,19,0 DATA_USAGE_FACT,UPDATION_DATE,TARGET_TABLE,UPDATION_DATE,29,9,19,0... (3 Replies)
Discussion started by: dips_ag
3 Replies

7. Shell Programming and Scripting

Script or command: Formatted text to CSV

Hi Everyone, I've been using this site as a great resource to aid me with simple search and replace tasks. I still consider myself a novice and now I've been pulling my hair out over this problem. Any hints or suggestions would be welcome! I have a text file in a format like this name:... (6 Replies)
Discussion started by: regexnub
6 Replies

8. Shell Programming and Scripting

creating & sending formatted (with bolds & colors) CSV

Hi , I have a situation. Need is to create & send a formatted file with header in BOLD & colored & some sequel results as a content. I know echo -e \033 command, but its scope is limited in PUTTY. How to retain the formatting out of Putty; say after someone opens a email attachment... (2 Replies)
Discussion started by: infaWorld
2 Replies
Login or Register to Ask a Question