I am a newb in unix. But i need to understand this code given by client :(. i tried to ask the client details about the code like what the code is supposed to do but he himself has no idea. So basically i am stuck with a code whose purpose i do not know but i have to understand what it does >.<.
This is what i have been able to make out of the code so far( in the form of comments) [1] [2] [3] etc..
I have doubts/no clue for comments number [8] to [12] . for [1] to [7] i feel most are right, but if any are wrong feel free to point out.
A little background : I am supposed to working in teradata and this might be related to it.
My comments are in bold{*}
#!/usr/bin/ksh **//[1] sets shell**
set -x **//[2]will this show the argument values before execution?**
l=$1 **//[3]$1,$2,$3 are the arguments with which this shell**
h=$2 **//is invoked.l= first argument h= second argument and**
k=$3 **//k=3rd argument.**
/export/home/someguy/daily_refresh/abc_mt_dt.ksh $l $h $k
**//[4] calling abc_mt_dt.ksh
// with arguments l h and k**
chmod 777 /export/home/someguy/daily_refresh/$k.txt
**// making $k.txt a read write n**
**//executable.This im sure im right**
while read line
do
echo $line |read a b c
**// [5] reads three values from keyboard and displays them as
//well as storing them in values a b and c**
DATA_START_DT=$a
**// [6] variables DATA_START_DT DATA_END_DT ID set to the three**
DATA_END_DT=$b **// values read from keyboard**
ID=$c
echo $DATA_START_DT **//[7] displaying the values read from keyboard**
echo $DATA_END_DT
echo $ID
rm -rf /export/home/someguy/daily_refresh/logs/abc_$DATA_END_DT.log
**//[8] rm -rf is to recursively remove files and folders ..
so what will this command do? will it remove all files and folders
inside /export/home/someguy/daily_refresh/logs/ ?**
bteq <<EOI > /export/home/someguy/daily_refresh/logs/abc_$DATA_END_DT.log 2>&1
**// [9] need explaination as to what this does.**
.run file = /export/home/someguy/logon_caracal.bteq **//[10]**
.MAXERROR 1; **//[11]**
DATABASE SOME_DATABASE; **//[12]**
[8] No, it will not remove all files and folders inside
/export/home/someguy/daily_refresh/logs/. It will only delete the file called/export/home/someguy/daily_refresh/logs/abc_$DATA_END_DT.log.In [9], the script executes the
bteqcommand.<< EOIis a here document. All the statements underneath, until the line containing the word EOI, are passed to thebteqprogram. These arebteqcommands, not shell commands. All the output and errors from thebteqprogram are written to/export/home/someguy/daily_refresh/logs/abc_$DATA_END_DT.log.[10] This is the file containing SQL requests and bteq commands which will be processed.
[11] A MAXERROR of 1 means that bteq will exit if an error level 2 or above occurs during processing.