Sponsored Content
Top Forums Shell Programming and Scripting Coding for GMT, sqlplus and related parameters Post 302529752 by WhoDatWhoDer on Friday 10th of June 2011 10:09:52 AM
Old 06-10-2011
Tools Coding for GMT, sqlplus and related parameters

Unix gurus,

I'm brand new here so go easy on me.

I'm trying to automate the following script to be added to crontab which will automate the deployment of five sql scripts based on day of week. I've got three questions pertaining to the following:

1. Our server date+time is running on GMT; how do I get perl to reflect day of week for GMT-4?
2. I'm not sure if my sqlplus parameters are correct. The hardcoded values passed DO need to have a single quotation mark included when being passed. Is the way I've coded it, correct?
3. Lastly, I'm calling sqlplus each time and passing user/passwd/sid for each script being called. Since each script should be running sequentially after each other, should I remove sqlplus for all subsequent calls? What is the best way to code this?




Code:
 
#!/bin/ksh
export USAGE="USAGE: `basename $0` -e <DBUSER> <DBPASSWD> <TNSNAME>"
if [ $# -lt 3 ]; then
  echo ${USAGE}
  exit 1;
fi
SCRIPTHOME=`home/users/pzx8pak`
TMS_USER=$1
TMS_PWD=$2
TMS_DATABASE=$3
LL="${TMS_USER}/${TMS_PWD}@${TMS_DATABASE}"
dow()  
{
 perl -e '
  use POSIX qw(strftime);
  $fmt = "%A";  # %a = abbreviated weekday %u = weekday number 
  $mday = substr("$ARGV[0]", 8, 2);
  $mon =  substr("$ARGV[0]", 5 ,2);
  $year = substr("$ARGV[0]", 0 ,4);
  $weekday =
    strftime($fmt, 0, 0, 0, $mday , $mon - 1, $year - 1900, -1, -1, -1);
  print "$weekday";
  ' "$1"
}
day = "$(dow `date "+%Y-%m-%d"` )"
 
if [[ ${day} = "Monday" ]]; then
 cd ${SCRIPTHOME}
 sqlplus -s ${LL} @./SCR_MTL_CST_TXN_COST_DETAILS_PRE_OUTAGE.sql "'2005'" "'01-JAN'" "'31-MAR'"
 sqlplus -s ${LL} @./MTL_MATERIAL_TRANSACTIONS_PRE_OUTAGE.sql "'2005'" "'01-JAN'" "'31-MAR'"
 sqlplus -s ${LL} @./RCV_TRANSACTIONS_PRE_OUTAGE.sql "'2005'" "'01-JAN'" "'31-MAR'"
 sqlplus -s ${LL} @./MTL_TXN_REQUEST_HDR_LINE_PRE_OUTAGE.sql "'2005'" "'01-JAN'" "'31-MAR'"
 sqlplus -s ${LL} @./RCV_SHIPMENT_HDR_LINE_PRE_OUTAGE.sql "'2005'" "'01-JAN'" "'31-MAR'"
 sqlplus -s ${LL} @./MTL_CYCLE_COUNT_ITEMS_PRE_OUTAGE.sql "'2005'" "'01-JAN'" "'31-MAR'"
elif [[ ${day} = "Tuesday" ]]; then
 cd ${SCRIPTHOME}
 sqlplus -s ${LL} @./SCR_MTL_CST_TXN_COST_DETAILS_PRE_OUTAGE.sql "'2006'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./MTL_MATERIAL_TRANSACTIONS_PRE_OUTAGE.sql "'2006'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./RCV_TRANSACTIONS_PRE_OUTAGE.sql "'2006'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./MTL_TXN_REQUEST_HDR_LINE_PRE_OUTAGE.sql "'2006'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./RCV_SHIPMENT_HDR_LINE_PRE_OUTAGE.sql "'2006'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./MTL_CYCLE_COUNT_ITEMS_PRE_OUTAGE.sql "'2006'" "'01-JAN'" "'31-MAR'" 
elif [[ ${day} = "Wednesday" ]]; then
 cd ${SCRIPTHOME}
 sqlplus -s ${LL} @./SCR_MTL_CST_TXN_COST_DETAILS_PRE_OUTAGE.sql "'2007'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./MTL_MATERIAL_TRANSACTIONS_PRE_OUTAGE.sql "'2007'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./RCV_TRANSACTIONS_PRE_OUTAGE.sql "'2007'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./MTL_TXN_REQUEST_HDR_LINE_PRE_OUTAGE.sql "'2007'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./RCV_SHIPMENT_HDR_LINE_PRE_OUTAGE.sql "'2007'" "'01-JAN'" "'31-MAR'" 
 sqlplus -s ${LL} @./MTL_CYCLE_COUNT_ITEMS_PRE_OUTAGE.sql "'2007'" "'01-JAN'" "'31-MAR'" 
elif [[ ${day} = "Thursday" ]]; then
 cd ${SCRIPTHOME}
 sqlplus -s ${LL} @./SCR_MTL_CST_TXN_COST_DETAILS_PRE_OUTAGE.sql "'2008'" "'01-JAN'" "'31-MAR'"   
 sqlplus -s ${LL} @./MTL_MATERIAL_TRANSACTIONS_PRE_OUTAGE.sql "'2008'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./RCV_TRANSACTIONS_PRE_OUTAGE.sql "'2008'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./MTL_TXN_REQUEST_HDR_LINE_PRE_OUTAGE.sql "'2008'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./RCV_SHIPMENT_HDR_LINE_PRE_OUTAGE.sql "'2008'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./MTL_CYCLE_COUNT_ITEMS_PRE_OUTAGE.sql "'2008'" "'01-JAN'" "'31-MAR'"  
 
elif [[ ${day} = "Friday" ]]; then
 cd ${SCRIPTHOME}
 sqlplus -s ${LL} @./SCR_MTL_CST_TXN_COST_DETAILS_PRE_OUTAGE.sql "'2009'" "'01-JAN'" "'31-MAR'"   
 sqlplus -s ${LL} @./MTL_MATERIAL_TRANSACTIONS_PRE_OUTAGE.sql "'2009'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./RCV_TRANSACTIONS_PRE_OUTAGE.sql "'2009'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./MTL_TXN_REQUEST_HDR_LINE_PRE_OUTAGE.sql "'2009'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./RCV_SHIPMENT_HDR_LINE_PRE_OUTAGE.sql "'2009'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./MTL_CYCLE_COUNT_ITEMS_PRE_OUTAGE.sql "'2009'" "'01-JAN'" "'31-MAR'"   
elif [[ ${day} = "Saturday" ]]; then
 cd ${SCRIPTHOME}
 sqlplus -s ${LL} @./SCR_MTL_CST_TXN_COST_DETAILS_PRE_OUTAGE.sql "'2010'" "'01-JAN'" "'31-MAR'"   
 sqlplus -s ${LL} @./MTL_MATERIAL_TRANSACTIONS_PRE_OUTAGE.sql "'2010'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./RCV_TRANSACTIONS_PRE_OUTAGE.sql "'2010'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./MTL_TXN_REQUEST_HDR_LINE_PRE_OUTAGE.sql "'2010'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./RCV_SHIPMENT_HDR_LINE_PRE_OUTAGE.sql "'2010'" "'01-JAN'" "'31-MAR'"  
 sqlplus -s ${LL} @./MTL_CYCLE_COUNT_ITEMS_PRE_OUTAGE.sql "'2010'" "'01-JAN'" "'31-MAR'"  
 
fi 
 
echo ""
echo ""
echo ""
echo "Deployments Complete"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing parameters from a shell script to sqlplus

Hi , I want to pass parameters from a shell script to a sql script and use the parameter in the sql query ..and then I want to spool a particular select query on to my unix box... for 4 different locations by writing only one sql script Right now no file is generated on the unix box...it is a... (2 Replies)
Discussion started by: phani
2 Replies

2. Shell Programming and Scripting

How to pass Shell variables to sqlplus use them as parameters

Hi, I am trying to pass some of the variables in my shell scripts to the sqlplus call and use them as parameters. For example, I would like to replace the 'SAS', and '20050612' with $var1 and $var2, respectively, how can I do that? --------------------------------------------------------... (1 Reply)
Discussion started by: Jtrinh
1 Replies

3. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

4. Shell Programming and Scripting

Help me about gmt scripts

does somebody know GMT mapping? please reply (2 Replies)
Discussion started by: SANGUINE
2 Replies

5. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

6. Shell Programming and Scripting

GMT to PST

I have a file which is tab delimited, it contains the GMT date. Please tell me how to convert from GMT to PST time and if the date and time is of 2 days ago from the current date store the lines in a file or else remove the line. 10.1.10.178 - - - 10.1.10.178 - - ... (2 Replies)
Discussion started by: sandy1028
2 Replies

7. Shell Programming and Scripting

Can't get shell parameters to pass properly to sqlplus

Gurus, The issue I'm having is that my Shell won't accept SQL parameters properly...... Here's they way I'm running it.... applmgr@ga006hds => sh CW_MigrationDeployScript.sh apps <appspwd> <SID> '01-JAN' '31-MAR' The process just hangs not submitting the SQL job... ... (3 Replies)
Discussion started by: WhoDatWhoDer
3 Replies

8. Shell Programming and Scripting

need downloading related help...but its not related to unix

Hi All, I am trying to dowmload the zip file "zkManageCustomers.zip " but i dont have access. Can anyone help me to download this file See the below link- http://www.ibm.com/developerworks/opensource/library/wa-aj-open/index.html?ca=drs- Please help me as early as... (1 Reply)
Discussion started by: aish11
1 Replies

9. Shell Programming and Scripting

Shell Script passing parameters to sqlplus code

Hello All, I am interested in finding out a way to pass parameters that are entered at the prompt from HP unix and passed to SQLPlus code with a Shell Script. Is this possible? Thanks (4 Replies)
Discussion started by: compprog11
4 Replies

10. Shell Programming and Scripting

Sqlplus error - sqlplus -s <login/password@dbname> : No such file or directory

i am using bash shell Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127. IFS="," declare -a Arr=($Variable1); SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE} echo "set head off ; " > ${SQLCMD} echo "set PAGESIZE 0 ;" >> ${SQLCMD}... (6 Replies)
Discussion started by: arghadeep adity
6 Replies
All times are GMT -4. The time now is 06:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy