We help IT Professionals succeed at work.
Get Started

UNIX Shell Scripting

IT_ETL
IT_ETL asked
on
922 Views
Last Modified: 2013-12-26
I am new to UNIX Shell Scripting. I have attached a shell script below as I have few basic questions. If someone could answer them then I would appreciate that.

1) progName=$(basename $0)
progName=${progName%.ksh}  -- What does it mean?

2) dbuser prod > /dev/null
newdb hhp1 > /dev/null -- What does it mean?

3) funcsLib=$SYSTEMHOME/funcs/dsextr_funcsLib -- What does it mean?

4) if [[ -a $funcsLib ]]; then
      . $funcsLib -- What does it mean?

5) WIP=yes -- What does it mean?

6) sqlNameN=$SQL/$progName"1.sql" -- What does it mean?

7) CheckWip $wipFile pull_date -- What does it mean?

8) if [ $? -eq 0 ]; then -- What does it mean?

9) cat <<- EOF > $tmpSql -- What does it mean?

10) sysStr=$(do_sql -@ hhp1 -i $tmpSql) -- What does it mean?

11) pTime=$(echo $sysStr | cut -d'|' -f1)
      cTime=$(echo $sysStr | cut -d'|' -f2) -- What does it mean?

12) sed "s@#PREVDATE#@$pTime@g;
      s@#CURDATE#@$cTime@g;
      s@#ORDATA#@$dataFileO@g" $sqlNameO > $sqlNameO2 -- What does it mean?

13) RegisterWip $wipFile pull_date -- what does it mean?








#!/bin/ksh
#====================================================================
# File name: NZCHECK_PYXIS.KSH
#====================================================================
. $HOME/.profile
 
progName=$(basename $0)
progName=${progName%.ksh}
 
system nz > /dev/null
dbuser prod > /dev/null
newdb hhp1 > /dev/null
 
# Source common functions into program.
funcsLib=$SYSTEMHOME/funcs/dsextr_funcsLib
mailRC=$SYSTEMHOME/etc/nzcheck_mail.rc
 
if [[ -a $funcsLib ]]; then
	. $funcsLib
else
	print "Can't find $funcsLib"
	exit 1
fi
 
if [[ -a $mailRC ]]; then
	. $mailRC
else
	print "Can't find $mailRC"
	exit 1
fi
 
# Initialize environment variables.
WIP=yes
 
CommonSetup
 
sqlNameN=$SQL/$progName"1.sql"
sqlNameN2=$SQL/$progName"1.2.sql"
sqlNameO=$SQL/$progName"2.sql"
sqlNameO2=$SQL/$progName"2.2.sql"
wipNameO=$LOG/$progName"2.2.sql."$runMonth".wip"
 
tmpSql=$TMP/$progName".sql"
tmpFile=$TMP/$progName.$$
dataFileN=$TMP/$progName"_nz.dat"
dataFileO=$TMP/$progName"_or.dat"
 
print "\npull_date"
CheckWip $wipFile pull_date
 
if [ $? -eq 0 ]; then
  print "   already done\n"
else
	cat <<- EOF > $tmpSql
		set echo off feedback off term off;
		set serveroutput on size 999999;
		declare
		ctime varchar2(20);
		ptime varchar2(20);
		begin
			select to_char(trunc(sysdate-1),'yyyymmdd hh24miss'),
			to_char(trunc(sysdate),'yyyymmdd hh24miss')
			into ptime,ctime
			from dual;
			dbms_output.put_line(ptime||'|'||ctime);
		end;
		/
		EOF
 
	sysStr=$(do_sql -@ hhp1 -i $tmpSql)
	if [ $? -ne 0 ]; then
		print "Attempt to get yesterday's date failed in nzcheck_pyxis:" > $tmpFile
		mailx -c"$NOTIFY_LIST_CC" -s"$NOTIFY_EPSUBJ" "$NOTIFY_LIST" < $tmpFile
		\rm $tmpFile > /dev/null 2>&1
		EXIT 1
	fi
 
	pTime=$(echo $sysStr | cut -d'|' -f1)
	cTime=$(echo $sysStr | cut -d'|' -f2)
 
	sed "s@#PREVDATE#@$pTime@g;
			 s@#CURDATE#@$cTime@g" $sqlNameN > $sqlNameN2
	sed "s@#PREVDATE#@$pTime@g;
			 s@#CURDATE#@$cTime@g;
			 s@#ORDATA#@$dataFileO@g" $sqlNameO > $sqlNameO2
	RegisterWip $wipFile pull_date
fi

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2013
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE