How to Connect to Teradata and Run in Shell Script?

Hi Master,

I need to create dan run script in linux to get data from teradata

I did this

---------- Post updated at 02:28 AM ---------- Previous update was at 02:25 AM ----------

LOG_DIR="/home/";
OUTDIR="/home/";
SCRIPT_NAME=�test";
DUMPFILE="${OUTDIR}${SCRIPT_NAME}"_"$(date +"%Y%m%d%H").txt";
USERID=�A12345";
PASWD=�B342a12";
LOGNAME="test_"$(date +"%Y%m%d%H")".sql";



#======================================================================================#
/usr/bin/bteq << END-OF-SQL >> ${LOG_DIR}${LOGNAME};
.logmech ldap;
.LOGON tdprod/${USERID},${PASWD};
.Set Format off
.Set Recordmode off
.Set Echoreq on
.Set Separator '|'
.width 3000
.Set Titledashes off
.Export REPORT FILE = ${DUMPFILE}


SELECT
        top 5*
FROM transactional_ldp


.Export Reset
.LOGOFF
.QUIT
END-OF-SQL

but it always ended up with errors

line 7: unexpected EOF while looking for matching `"'
line 33: syntax error: unexpected end of file

Please help

The first double-quote character on the line:

SCRIPT_NAME=�test";

is the wrong character. Change that line to:

SCRIPT_NAME="test";

and try again.

1 Like

huge thanks Sir Don, its solved