I have the below script
i am getting the csv in garbled format.Please suggest the changes.
SUNOS
#######################################################################
####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