Sponsored Content
Top Forums Shell Programming and Scripting Some env setting is causing the script not to work ? Post 100890 by uuser on Thursday 2nd of March 2006 02:21:07 PM
Old 03-02-2006
Some env setting is causing the script not to work ?

Not sure what has changed in the Unix environment.
The following script which was working is now not working.

Code:
#!/usr/bin/ksh
# -----------------------------------------------------------------------------
# File:      monitor_db.sh
#
# -----------------------------------------------------------------------------
cd ~
. .profile

# Parameters used
# ORA_LOG,ORA_SCRIPT,DBA_EMAIL_LIST   -- (set in .profile)
#

cat $ORA_SCRIPT/orasid.lst | while read LINE1
do
  cat /etc/oratab | while read LINE
  do
  case $LINE in
  \#*)            ;;      #comment-line in oratab
  *)
  #       Proceed only if third field is 'Y'.
 if [ "`echo $LINE | awk -F: '{print $1}' -`" = $LINE1 ] ; then
 export ORACLE_SID=$LINE1
 export ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`

#
# CHECK FOR ALL DB if Up/Down
#

  if [ -f $ORA_LOG/pmon_process_exist.txt ] ; then /bin/rm $ORA_LOG/pmon_process_exist.txt; fi
  ps -ef | grep ora_pmon_$ORACLE_SID | grep -v grep  > $ORA_LOG/pmon_process_exist.txt
  if [ -s $ORA_LOG/pmon_process_exist.txt ]
  then
        if [ -f $ORA_LOG/select.lst ] ; then /bin/rm $ORA_LOG/select.lst; fi
        $ORACLE_HOME/bin/sqlplus -s ora_connect/ora_connect@$ORACLE_SID @$ORA_SCRIPT/select.sql
        if [ -s $ORA_LOG/select.lst ]
        then
                echo "DB ALL OK"
        else
        for dba in `cat $ORA_SCRIPT/DBA_EMAIL_LIST`
        do
                /usr/bin/mailx -s "PMON is up but DATABASE HAS CONNECTIVITY ISSUES: $ORACLE_SID" $dba < /dev/null
        done
        fi
  else
    for dba in `cat $ORA_SCRIPT/DBA_EMAIL_LIST`
    do
        /usr/bin/mailx -s "DATABASE IS DOWN: $ORACLE_SID" $dba < /dev/null
    done
  fi
  rm $ORA_LOG/pmon_process_exist.txt
 fi
esac
done
echo $LINE1
echo $ORACLE_SID
echo $ORACLE_HOME
done


This is the culprit.
Code:
ps -ef | grep ora_pmon_$ORACLE_SID | grep -v grep  > $ORA_LOG/pmon_process_exist.txt

For some reason this is now generating an empty file thus making the logic fto ail and eventually the purpose of script. So even if the pmon process is not up it thinks it is since the file exist ? ANy idea of what have happened that all of a suddent the same script is not working ?
 

10 More Discussions You Might Find Interesting

1. Solaris

setting env

I am trying to set up my compiler, but when I go to look for gcc it not found but I get a message that stayed (/usr/oasys/bin) and when I go into the dir to set my env the following is type cp : cannot creat //pref/.environ: no such file or directory and I input ./setenv PATH=... (3 Replies)
Discussion started by: alsande
3 Replies

2. AIX

edit env. setting

hi eveybody, i m trying to set acl using acledit command in AIX box but wat im gettung is 3002-100 acledit: EDITOR environment variable not set can anyone help me out how 2 set editor.................... thanks in advance (4 Replies)
Discussion started by: rrlog
4 Replies

3. Red Hat

Help with csh env setting in Fedora 8

Hi there, How can I change bash to csh when starting a terminal, and set some aliases for csh? I can't find such files like .cshrc in my home directory. Thanks a lot (1 Reply)
Discussion started by: dustinwang2003
1 Replies

4. UNIX for Dummies Questions & Answers

Setting env variables using script

Hi, I wrote two small scripts to set env variables in a shell. java_env.csh #!/bin/csh -fn setenv JAVA_HOME '/scratch/software/jdk1.5.0_11' setenv PATH $PATH':'$JAVA_HOME'/bin' and run it using csh ./java_env.csh But the env variables are not set. I tried running each line on the... (5 Replies)
Discussion started by: NoviceAmod
5 Replies

5. Shell Programming and Scripting

Issue with a Unix script Env setting

Hi, I have the below script #------------------------------------------------------------------------------ #Set up environment variables #------------------------------------------------------------------------------ SCRIPTS_DIR=/remedy/scripts/ServerVolumeBilling... (3 Replies)
Discussion started by: anilvaranasi_02
3 Replies

6. Ubuntu

Does /dev/ttyUSB* causing my usb 3G Dongle doesn't work when plug-in

Hi, Is someone knows how or maybe the caused why my USB 3G dongle doesn't work when plug-in after boot the /dev/ttyUSB* I wonder how this /dev/ttyUSB1-4 works, i had a 3G USB dongle for my internet connection before i used lucyd lynx this the same USB dongle works fine when i plug-in after... (2 Replies)
Discussion started by: jao_madn
2 Replies

7. Shell Programming and Scripting

tcsh env setting using shell script

Hi All, I have made a file file usercreate.sh & it has to run in tcsh env & needs some path to be set. my script is as below. ########################## #!/bin/csh setenv PATH "/usr/lib/java/class" setenv LD_LIBRARAY_PATH ########################### but when i am ruuning my script... (1 Reply)
Discussion started by: ajaincv
1 Replies

8. Web Development

Deny from env=env-variable Does not work

(Above from Apache docs). On my system, using: SetEnvIf User-Agent Mozilla IsBad=1 Order allow,deny Allow from all Deny from env=IsBad ...I see that environment variable is set (using phpinfo()) but the page is still served. No errors in the Apache logs. (1 Reply)
Discussion started by: gnurob
1 Replies

9. Shell Programming and Scripting

Shell Script for Setting Env Variables

Hello All. Good Afternoon. I need one small help regarding setting of env variables for a particular host by getting it from the DB. For ex : 1. I am using LOCALHOST. 2. When I run a ./hostset.sh it should pick up the Oracle home details from associated DB and set it. Please... (1 Reply)
Discussion started by: PavanPatil
1 Replies

10. Shell Programming and Scripting

Setting ENV variables in PERL

I have perl script and in the first line we are invoking .sh script to set ENV variables. e..g eval '. $envfile; exec $PERL -S $0 "$@"' I want to change some of the env variables while the program is running and I am settging it like this .. $ENV{ORACLE_HOME}=trim($oraclehome);... (1 Reply)
Discussion started by: talashil
1 Replies
GIT-SH-SETUP(1) 						    Git Manual							   GIT-SH-SETUP(1)

NAME
git-sh-setup - Common git shell script setup code SYNOPSIS
. "$(git --exec-path)/git-sh-setup" DESCRIPTION
This is not a command the end user would want to run. Ever. This documentation is meant for people who are studying the Porcelain-ish scripts and/or are writing new ones. The git sh-setup scriptlet is designed to be sourced (using .) by other shell scripts to set up some variables pointing at the normal git directories and a few helper shell functions. Before sourcing it, your script should set up a few variables; USAGE (and LONG_USAGE, if any) is used to define message given by usage() shell function. SUBDIRECTORY_OK can be set if the script can run from a subdirectory of the working tree (some commands do not). The scriptlet sets GIT_DIR and GIT_OBJECT_DIRECTORY shell variables, but does not export them to the environment. FUNCTIONS
die exit after emitting the supplied error message to the standard error stream. usage die with the usage message. set_reflog_action set the message that will be recorded to describe the end-user action in the reflog, when the script updates a ref. git_editor runs an editor of user's choice (GIT_EDITOR, core.editor, VISUAL or EDITOR) on a given file, but error out if no editor is specified and the terminal is dumb. is_bare_repository outputs true or false to the standard output stream to indicate if the repository is a bare repository (i.e. without an associated working tree). cd_to_toplevel runs chdir to the toplevel of the working tree. require_work_tree checks if the repository is a bare repository, and dies if so. Used by scripts that require working tree (e.g. checkout). get_author_ident_from_commit outputs code for use with eval to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit. AUTHOR
Written by Linus Torvalds <torvalds@osdl.org[1]> DOCUMENTATION
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org[2]>. GIT
Part of the git(1) suite NOTES
1. torvalds@osdl.org mailto:torvalds@osdl.org 2. git@vger.kernel.org mailto:git@vger.kernel.org Git 1.7.1 07/05/2010 GIT-SH-SETUP(1)
All times are GMT -4. The time now is 05:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy