YZlat
asked on
oraenv not found error
In my ksh script i set the environmental variables as follows:
#!/bin/ksh
ORAENV_ASK=NO
export ORACLE_SID=ORCL
. oraenv
export ORACLE_HOME
when I run the script manually, it runs fine, but when I run it via crontab, I get this error.
How can I avoid getting this error. Should I try using
. ${HOME}/.profile
or
. /home/oracle/.profile ${ORACLE_SID}
?
#!/bin/ksh
ORAENV_ASK=NO
export ORACLE_SID=ORCL
. oraenv
export ORACLE_HOME
when I run the script manually, it runs fine, but when I run it via crontab, I get this error.
How can I avoid getting this error. Should I try using
. ${HOME}/.profile
or
. /home/oracle/.profile ${ORACLE_SID}
?
Put your environment and explicit paths into the shell script.
ASKER
The thing is I want it to be dynamic, that's the whole reason I removed the explicit path that was hardcoded
When you run any script via crontab you need to set for it environment, and when you refer to files or directories then you refer by full path names. You could try the following before sourcing the oraenv file:
cd
OR
cd ~
cd
OR
cd ~
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My initial suggestion was to add the fully qualified oraenv path. Also, I've seen one workaround by adding the profile to the cron line: "$HOME/.profile; /u01/scripts/somescript.sh "
ASKER
I changed . oraenv to . /usr/local/bin/oraenv
and now I am getting an error when trying to export ORACLE_HOME:
/home/oracle/Scripts/MyScr ipt.ksh[16 ]: dbhome: not found.
I checked /usr/local/bin and dhome exists there
and now I am getting an error when trying to export ORACLE_HOME:
/home/oracle/Scripts/MyScr
I checked /usr/local/bin and dhome exists there
>>I am getting an error when trying to export ORACLE_HOME
oraenv does this for you.
In your crontab script above the oraenv call:
export PATH=/usr/local/bin:$PATH
oraenv does this for you.
In your crontab script above the oraenv call:
export PATH=/usr/local/bin:$PATH
ASKER
/usr/local/bin is already in $PATH
I changed my code to:
ORAENV_ASK=NO
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$PAT H
. /usr/local/bin/oraenv
export ORACLE_HOME
but still getting the same error.
Btw, could you tell me what does ORAENV_ASK=NO do?
I changed my code to:
ORAENV_ASK=NO
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$PAT
. /usr/local/bin/oraenv
export ORACLE_HOME
but still getting the same error.
Btw, could you tell me what does ORAENV_ASK=NO do?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks. So how should I modify my code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It ran, looks like it is working! Thank you!
So . oraenv exports ORACLE_HOME automatically?
So . oraenv exports ORACLE_HOME automatically?
>>So . oraenv exports ORACLE_HOME automatically?
Not 100% sure about exporting but it does set it for the rest of the script. It also adds $ORACLE_HOME/bin to your PATH.
It sets up your ORAcle ENVironment. Hence the name: oraenv.
Not 100% sure about exporting but it does set it for the rest of the script. It also adds $ORACLE_HOME/bin to your PATH.
It sets up your ORAcle ENVironment. Hence the name: oraenv.
ASKER
one more thing, if I run my script from crontab, I need to set my $PATH again, regardless what it is set to outside of crontab?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks so much for all your help!