Same KSH behaving differently on diff servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Same KSH behaving differently on diff servers
# 1  
Old 01-30-2012
Same KSH behaving differently on diff servers

HI all

I have written a ksh to execute PL/sql procedure and generate the log file. The script is working fine to the extent of calling the taking input, executing PL/SQL procedure.

On one server the log file is getting generated properly. i,e it shows the DBMS output . The log file size was something like 378 bytes

But after running the same script on another the DBMS output is getting repeated in the log file and the log file size is like 1MB.

There are no errors getting shown in the logs.

In both the files the only difference is the oracle home variable and the path variable which i have set in separate export statements.

Can anyone please suggest any ideas as to why this is happening.
# 2  
Old 01-30-2012
Both the servers are connected to the same DB? If not, the data may be inconsistent across the 2 DB's.

--ahamed
# 3  
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
# 4  
Old 01-30-2012
Quote:
exec 1>${LOGFILE} 2>&1
What is this line for? Appears to conflict with another processes later in the script which writes to ${LOGFILE}.
Quote:
sqlplus -S $DBASE_LOGIN/$DBASE_PWD@$DBASE_HOST << EOF > ${LOGFILE}

Last edited by methyl; 01-30-2012 at 12:05 PM..
# 5  
Old 01-30-2012
Does your PL/SQL behave properly both place when run interactively? -- then it most likely is env variables.

Different servers == different environment variables, which is the first place to look.
By default they cannot be completely identical.

Try the following, add this command to the script:
Code:
set >  /tmp/env_vars.`hostname`

next, get both env_vars.* files in a single directory, maybe ftp/sftp. Run the diff
command.
This User Gave Thanks to jim mcnamara For This Post:
# 6  
Old 01-30-2012
I am very suspicious of line 73:
Quote:
cat ${LOGFILE}
This has the potential to loop because it just displays the log into space which is then picked up by the weird "exec" line I highlighted in my earlier post.

Are you 100% sure that the two scripts are bit-identical? (Try "cksum").
This User Gave Thanks to methyl For This Post:
# 7  
Old 01-30-2012
MySQL

Thank you for your suggestions methyl and jim. Will try them out both and let you know Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question