Sponsored Content
Top Forums Shell Programming and Scripting Same KSH behaving differently on diff servers Post 302594067 by ramakrishnakini on Monday 30th of January 2012 10:34:09 AM
Old 01-30-2012
my script uses sql plus to connect to the DB. The problem is occuring when i run the script on the server which is the same as that DB.

here is my script:
Code:
#!/bin/ksh  

. ${BINDIR:=./}/RIM_input.txt

export ORACLE_HOME=/usr/local/opt/oracle/product/10.2.0.5
export PATH=$ORACLE_HOME/bin:$PATH:

DBASE_HOST=$DB_HOST
DBASE_LOGIN=$DB_LOGIN
DBASE_PWD=$DB_PWD
procename=${1}
comit=${2}
sleep=${3}

#. /home/adba/.profile


EMAIL_ADBA=$EMAIL

DATE=$(date "+%Y-%m-%d.%H:%M:%S")

CMDNAME=${0}

SHORTCMDNAME=$(print ${CMDNAME} | awk -F/ '{print $NF}')

HOSTNAME=`hostname`

#################################################################
#################################################################

LOGFILE=${SHORTCMDNAME}_${procename}_${DATE}.log
exec 1>${LOGFILE} 2>&1
print "\n${SHORTCMDNAME}  STARTING => $(date "+%A %B %d, %Y %H:%M:%S")\n"

#################################################################
#################################################################

function Send_Error {

  cat ${LOGFILE}|mailx -s "ERROR: ${procename}" ${EMAIL_ADBA}
  print "\nERROR: ${procename}"
  print "       Sent to ${EMAIL_ADBA} "
  print "\n${SHORTCMDNAME}  ABORTING => $(date "+%A %B %d, %Y %H:%M:%S")\n"
  exit 1
}

function Send_Msg {

#(cat $LOGFILE; uuencode ./${LOGFILE} ./${LOGFILE}) | mailx -s "Message: ${procename}" ${EMAIL_ADBA}

cat ${LOGFILE}|mailx -s "Message: ${procename}" ${EMAIL_ADBA}

#uuencode ${LOGFILE} ${LOGFILE} | mailx -s "Message: ${procename}" ${EMAIL_ADBA}
  print "\nMessage: ${procename}"
  print "         Sent to ${EMAIL_ADBA} "
  print "\n${SHORTCMDNAME}  ENDING => $(date "+%A %B %d, %Y %H:%M:%S")\n"
  exit 0
}


function Delete_Records {

print "\nMessage: Starting ${0} at $(date "+%A %B %d, %Y        %H:%M:%S")" 

sqlplus -S $DBASE_LOGIN/$DBASE_PWD@$DBASE_HOST  << EOF > ${LOGFILE}
set echo on
set time on
set timing on
set serveroutput on size 1000000
exec ${procename}(${comit}, ${sleep});
EOF

 cat ${LOGFILE} 

 if [[ ! -s ${LOGFILE}  ]]; then
   Send_Error "Error in ${LOGFILE}  File is empty or does not exist."
 elif [[ $(grep -c "ORA-" ${LOGFILE}) -ne 0 ]]; then
   Send_Error "Error in ${LOGFILE}.  Oracle error found."
 elif [[ $(grep -c "procedure successfully completed." ${LOGFILE}) -ne 1 ]]; then
   Send_Error "Error in ${LOGFILE}.  Unknow error found."
 fi

print "\nMessage: Ending ${LOGFILE} at $(date "+%A %B %d, %Y        %H:%M:%S")"  

}

#########################################################

if [[ ${procename} = "" || ${comit} = "" || ${sleep} = "" ]]; then
  print "Syntax Error >${SHORTCMDNAME} ${procename}  ${comit} ${sleep}"
   print "PROCNAME=${procename}"
   print "COMMITFREQUENCY=${comit}"
  print "SLEEP=${sleep}"
  Send_Error "Syntax Error in ${SHORTCMDNAME}"
fi

print "\nMessage: Starting ${SHORTCMDNAME} at $(date "+%A %B %d, %Y        %H:%M:%S")"
print "Message: Parameters PROCNAME COMMITFREQUENCY SLEEP " 
print "Message: Parameters ${procename} ${comit} ${sleep}" 
print "Message: Logs can be found in:\n`pwd`  "

Delete_Records ${procename} ${comit} ${sleep}

print "\n${SHORTCMDNAME}  Complete => $(date "+%A %B %d, %Y        %H:%M:%S")\n"
Send_Msg "${SHORTCMDNAME} is Complete"


Last edited by methyl; 01-30-2012 at 11:51 AM.. Reason: please use code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Script behaving differently in Crontab..

I posted this in Shell scripting... maybe I'll try it in this forum.. ***************** I wrote a script to stop a process,truncate its log files and re-start the process... We are using Progress Software in Unix ( Sun Sparc) When ever I start this progress program , it should kick off a... (1 Reply)
Discussion started by: newtoxinu
1 Replies

2. Shell Programming and Scripting

Script behaving differently in Crontab..

Hi, I wrote a script to stop a process,truncate its log files and re-start the process... We are using Progress Software in Unix ( Sun Sparc) When ever I start this progress program , it should kick off a C pgm in the background.. The script work perfectly fine when I run it from command... (4 Replies)
Discussion started by: newtoxinu
4 Replies

3. UNIX for Advanced & Expert Users

Script behaving differently on two servers

All, I have a script that runs on 2 servers and there seems to be something wrong. It's producing different results on the 2 servers. Here is the script on server1 which is behaving correctly but on 2 behaving differently. 2nd server: I couldn't make out whats the error is?... (5 Replies)
Discussion started by: mhssatya
5 Replies

4. UNIX for Dummies Questions & Answers

awk command behaving differntly on 2 servers--urgent

Hi I am using awk command for string replacement. I have 2 servers. The command runs perfectly well on 1st server On the second server when i run the command on the same datset The command gets stuck while processing a large piece of record.. Does it have anything to with setting on the 2... (1 Reply)
Discussion started by: aixjadoo
1 Replies

5. Shell Programming and Scripting

Why is a variable behaving differently in ksh script.

Guys i have strange behaviour with command output being saved in a variable instead of a tmp file. 1. I suck command output into a variable Sample command output # cleanstats DRIVE INFO: ---------- Drv Type Mount Time Frequency Last Cleaned Comment *** ****... (1 Reply)
Discussion started by: lavascript
1 Replies

6. IP Networking

how to cp between servers on diff network

Hi, how can i sftp or scp between 2 servers, when only i am able to ping to them. they are on different network 10.130.170.31 -- server 1 10.130.230.141 -- server 2 i need to transfer data files from 1 to 2. need your suggestions or help on these. Regards saha (4 Replies)
Discussion started by: saha
4 Replies

7. Shell Programming and Scripting

sed and cut behaving differently

I have attached a file with few records. First 2 characters of each record are binary characters. I can remove it by and it works fine. But is behaving differently and removing more than expected characters. Can someone help me in accomplishing it through sed? Thanks in advance. (13 Replies)
Discussion started by: amicon007
13 Replies

8. Shell Programming and Scripting

jobs command behaving differently in script

Here is my test script: #!/bin/sh result=`jobs` echo " Jobs: "$result result=`ls` echo " LS "$result Here is the output: Jobs: LS 0 1 2 3 4 5 6 7 gcd initialize.sh #inter_round_clean.sh# inter_round_clean.sh inter_round_clean.sh~ look parallel_first_run.sh... (3 Replies)
Discussion started by: nealh
3 Replies

9. Shell Programming and Scripting

Comparision of two directories of diff servers

Hi All, I have transferred some directory structures from server1 to server2 by creating a tar files. Now i need to cross check whether I transferred entire structures or not. Is there any command to check this on each individual server. Thanks (2 Replies)
Discussion started by: nag_sathi
2 Replies

10. Filesystems, Disks and Memory

Different partitions of a drive behaving differently in Windows

I have a memory card of my Nokia N73 attached to laptop. There are a few partitions. Why all partitions behave differently? As clear from the attachments, for some partition, delete option is disabled. See 'Disk 1' which is my memory card. Here, patition 'G' (CHECK), i created in windows. The... (6 Replies)
Discussion started by: ravisingh
6 Replies
All times are GMT -4. The time now is 01:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy