Code:
#------------------------------------------------------------------------------
#Set up environment variables
#------------------------------------------------------------------------------
SCRIPTS_DIR=/remedy/scripts/ServerVolumeBilling
EXTRACT_DIR=/remedy/scripts/ServerVolumeBilling
WORKING_DIR=/remedy/scripts/ServerVolumeBilling
TODAYS_DT=`date +"%m/%d/%Y"`
LOG_DIR=/remedy/scripts/ServerVolumeBilling/Logs
TODAYS_DT=`date "+%m/%d/%y"`
TODAYS_DD=`date "+%d"`
TODAYS_MM=`date "+%m"`
TODAYS_YY=`date "+%y"`
TODAYS_DOW=`date "+%a"`
TODAYS_CCYY=`date +"%Y"`
TODAYS_CCYY_DT=`echo $TODAYS_MM$TODAYS_DD$TODAYS_YY | sed 's/ //g'`
#------------------------------------------------------------------------------
#Variables for Sqlplus
#------------------------------------------------------------------------------
#export TNS_ADMIN=/opt/oracle/product/10g_client/network/admin
#export ORACLE_BASE=/u01/app/oracle/
#export ORACLE_HOME=/opt/oracle/product/10g_client/
#export LD_LIBRARY_PATH=/usr/ar/cidcsremdapp1/bin:$ORACLE_HOME/lib32:$ORACLE_HOME/lib:/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/:/usr/lib:/usr/ucblib
#export LD_LIBRARY_PATH=/usr/ar/ftdcsremdapp1/bin:$ORACLE_HOME/lib32:$ORACLE_HOME/lib:/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/:/usr/lib:/usr/ucblib
export LD_LIBRARY_PATH=/usr/ar/cidcsrempapp1/bin:$ORACLE_HOME/lib32:$ORACLE_HOME/lib:/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/:/usr/lib:/usr/ucblib
#export PATH=$ORACLE_HOME/bin:$PATH
#export ORACLE_SID=rems1
#export ORACLE_SID=remd1
export ORACLE_SID=remp1
export TWO_TASK=ftdcsremsora1_rems1.WORLD
#export TWO_TASK=cidcsremdora1_remd1.WORLD
#export TWO_TASK=cidcsrempora1_remp1.WORLD
#SQLPLUS_PATH='/opt/oracle/product/10.2.0/bin'
SQLPLUS_PATH='/opt/oracle/product/10g_client/bin'
SQLPLUS_DIR=/remedy/scripts/ServerVolumeBilling
#------------------------------------------------------------------------------------
#Variables for file headers
#------------------------------------------------------------------------------------
HEADER='"SOURCE ID","ACCTG YR","ACCTG MO","ACCTG DAY","SUBMITTED_BY","COMPONENT_ID","WWID","BOOKING CODE","RESP CODE","CUSTOMER_CODE","VOLUME","REGION","REF1
","REF2","REF3","REF4"'
cat /dev/null > $EXTRACT_DIR/svb_report_macro_today.csv
echo $HEADER > $EXTRACT_DIR/svb_report.$TODAYS_CCYY_DT.csv
echo `date`:Running the macro
"ServerVolumeBillingScript.sh" 59 lines, 3409 characters
/usr/ar/cidcsrempapp1/bin/arsystem env sh
/usr/ar/cidcsrempapp1/bin/runmacro -o /remedy/scripts/ServerVolumeBilling/svb_report_macro_today.csv -x cidcsrempapp1 -U Demo -P demo -f TCS_AST:SBS_Reportin
gForm -t csv -n -O -q -z /remedy/scripts/ServerVolumeBilling/qualification
echo `date`:Completed Running the macro
echo `date`:Started parsing the file
awk '{print $10",",$19",",$18",",$17",",$16",",$15",",$14",",$13",",$12",",$11",",$25",",$22",",$21",",$23",",$24",",$20}' FS="," < $EXTRACT_DIR/svb_report_m
acro_today.csv > output1.csv
sed -e 's/ "//g' output1.csv > output2.csv
sed -e 's/"//g' output2.csv > output4.csv
sed -e 's/, /,/g' output4.csv > output5.csv
sed -e '1d' output5.csv >> $EXTRACT_DIR/svb_report.$TODAYS_CCYY_DT.csv
scp $EXTRACT_DIR/svb_report.$TODAYS_CCYY_DT.csv nacolx-VolumeBilling@cidcssftp01.ced.corp.cummins.com: >> $LOG_DIR/svbdata.log