Sponsored Content
Top Forums Shell Programming and Scripting How to write BTEQ batch scripts in UNIX? Post 302949301 by Shilpi Gupta on Thursday 9th of July 2015 02:34:19 AM
Old 07-09-2015
Hi Neutronscott,

Please find below code:

Code:
  
 clear
 DB_FIND()
 {
  IFS=$'\n'
  set -f
  echo "=================$BTEQ_NAME=================="
  while read i; do
  DB_Name=$i
  /usr/xpg4/bin/awk -v target=$DB_Name '{for(i=1;i<=NF;i++)if($i ~ target) print $(i)}' $BTEQ_NAME  > ${DB_Name}_TableList.txt
  sed '/FOLDR/d' ${DB_Name}_TableList.txt > ${DB_Name}_IFile.txt
  /usr/xpg4/bin/awk '!x[$0]++' ${DB_Name}_IFile.txt > ${DB_Name}_File.txt
  rm ${DB_Name}_IFile.txt
  rm ${DB_Name}_TableList.txt
  if [ -s ${DB_Name}_File.txt ] ; then
     echo ${DB_Name}_File.txt
      conn_string=`ksh /apps/cronacle/tools/teradata/.otherdetails/.Info_4ETL.sh UID_ODS_CLP_DRG`
     export conn_string;
     bteq <<EOF
     .logon ${conn_string};
     .export report FILE = /ftp/SrcFiles/src/SSSS/sample.txt;
     .SET SEPARATOR '|'
     SELECT * FROM dbc.tables where tablename='AP_INVC_F_V';
     .logoff
     .quit;
     EOF
 
  fi;
   done <Param.txt
 
}
  
 # Main Body of this Script
BTEQ_NAME_LIST=$1
 
for i in `cat ${BTEQ_NAME_LIST}` ; do
BTEQ_NAME=`echo "${i}" | awk -F"|" '{ print $1 }'`;
export BTEQ_NAME;
 BTEQ_PARAM_FILE=`awk '{for(i=1;i<=NF;i++)if($i~/\/bin/)print $(i)}' $BTEQ_NAME|cut -d"/" -f8|cut -d";" -f1`
 awk '{for(i=1;i<=NF;i++)if($i~/\=/)print $(i)}' $BTEQ_PARAM_FILE|cut -d"=" -f1 > ParamP1.txt
 awk '{for(i=1;i<=NF;i++)if($i~/_/)print $(i)}' ParamP1.txt > Param.txt
 #rm ParamP1.txt
 DB_FIND
 #rm Param.txt
 done


Getting Output as:

./DB_Validation_1.sh: line 66: syntax error: unexpected end of file

This script was working fine, when I m not inserting any Bteq batch inside it..

Please help me to find root cause behind this..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Learning to write UNIX Shell Scripts

Hi All, I am relatively new to UNIX. I know some basic commands. I am learning to write shell scripts. My first aim is to connect to a Data Base via shell script. Any ideas on this? Any links, docs which will tell me about scripting?? Thanks VEN (1 Reply)
Discussion started by: VENC22
1 Replies

2. UNIX for Dummies Questions & Answers

How can I run scripts in my unix account from batch file in Windows?

Hi all, I'm working on Windows, connecting to my Unix account by different ways: by FTP opening files in UltraEdit32, by mapping drive to browse, by Exceed or Telnet to compile at Unix account. Actually, that is what I would like to change: I'd like to make a batch file which would connect to... (7 Replies)
Discussion started by: olgafb
7 Replies

3. Shell Programming and Scripting

How to write a Script to run series of batch jobs on unix platform

Im new to unix shell scripting, I have to run batch jobs on unix. for example i have 5 jobs. first 2 can kickoff parallely. after completely finishing the 2 previous jobs the 3 job should kick off..once 3rd is over 4 th and 5th can kick off parallely. Each jobs run for 1 or 2 hours each. How to... (2 Replies)
Discussion started by: venki311
2 Replies

4. Shell Programming and Scripting

Running shell scripts automatically without using Batch or at commands

I have been trying to run a unix script which contains many sql statements.I need to run this script every monday morning. I tried to run on command prompt, it works fine. But while I run it via batch or at command., it returns with library module could not be loaded (libcompat.1.o could not be... (3 Replies)
Discussion started by: ritzwan0
3 Replies

5. Shell Programming and Scripting

HowTo translate KSH Scripts to DOS Batch Files ?

Hi there, in near future I have to change my work surrounding from HP UNIX to Windows Vista (great to get rid of old hardware :), but bad to loose UNIX :( ). As I heavily use KSH scripts to do my job, I was wondering, if there is any HowTo available, supporting me in re-writing the scripts to... (4 Replies)
Discussion started by: Joe-K7
4 Replies

6. Shell Programming and Scripting

How to batch-processing numerous shell scripts?

How to batch-processing numerous shell scripts? how to record the result of all the scripts as a report? then, I can analysis the process result. I want to process numerous shell scripts in my working directory: the directory name is consistent with shell scripts name, that is to say,... (2 Replies)
Discussion started by: qcmao
2 Replies

7. Shell Programming and Scripting

Batch write multiple usb in same time

Hi there, I would write a bash script to format then create a range of folder (folder name is number) to a usb stick. for numbers in $(seq -w 001 999) do pause "Press any key to start" mkfs.vfat -F32 /dev/sdc1 mount /dev/sdc1 /media/usb mkdir /media/$numbers umount /dev/sdc1... (8 Replies)
Discussion started by: wayneliao38
8 Replies

8. Shell Programming and Scripting

Teradata connectivity through UNIX by use bteq

Hi, I want a script for connecting teradata to load the file to teradata table. Can you please help me out. Thanks in advance. (1 Reply)
Discussion started by: victory
1 Replies

9. UNIX for Dummies Questions & Answers

Need equialent command for batch scripts

Hi Friend, what is the equivalent command for batch scripting of tail -1. for example : i have a.txt file with below the contents. i need to print last line --------------------------------- Use descriptive thread titles when posting. For example, do not post questions with subjects like... (3 Replies)
Discussion started by: Jewel
3 Replies

10. AIX

How to write a script to run without password on a batch of servers?

I need run a command such as ps -ef |grep xxx on a batch of servers, how to write a script to run it without password? don't need go in each server to check? Thanks (7 Replies)
Discussion started by: rainbow_bean
7 Replies
clear(3XCURSES) 					  X/Open Curses Library Functions					   clear(3XCURSES)

NAME
clear, erase, wclear, werase - clear a window SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int clear(void); int erase(void); int wclear(WINDOW *win); int werase(WINDOW *win); DESCRIPTION
The clear() and erase() functions clear stdscr, destroying its previous contents. The wclear() and werase() functions perform the same action, but clear the window specified by win instead of stdscr. The clear() and wclear() functions also call the clearok() function. This function clears and redraws the entire screen on the next call to refresh(3XCURSES) or wrefresh(3XCURSES) for the window. The current background character (and attributes) is used to clear the screen. PARAMETERS
win Is a pointer to the window that is to be cleared. ERRORS
OK Successful completion. ERR An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
bkgdset(3XCURSES), clearok(3XCURSES), clrtobot(3XCURSES), clrtoeol(3XCURSES), doupdate(3XCURSES), libcurses(3XCURSES), refresh(3XCURSES), wrefresh(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 clear(3XCURSES)
All times are GMT -4. The time now is 01:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy