The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
environment variables radhika03 Shell Programming and Scripting 3 01-22-2007 10:58 AM
Variables are not getting exported while running the script in cronjob csaha Shell Programming and Scripting 7 03-21-2006 01:32 PM
environment variables sumsin High Level Programming 6 03-13-2006 08:17 AM
help..Environment variables... sekar sundaram UNIX for Dummies Questions & Answers 3 08-30-2005 12:35 AM
environment variables spavlov UNIX for Dummies Questions & Answers 3 08-20-2003 06:49 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-30-2006
Registered User
 

Join Date: Jan 2006
Posts: 126
Environment variables causing cronjob to fail

I am trying to run a script which makes use of these environment variables, hence i need to export them out.

i've posted a similar post in an oracle forum. I've posted the same qn here to get some advise on the scripting aspect.

i execute my program in an unix environment by typeing "export_file.sh myscript.pl" at the prompt.
it runs successfully. However when i set cronjob
0 2 * * * export_file.sh myscript.pl, i get a load of error messages.

my export file----------
Code:
export ORACLE_BASE=/directory1/oracle
export ORACLE_HOME=/directory1/oracle/product/9.0.1
export ORACLE_TERM=386
export LC_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=.:$PATH:$ORACLE_HOME/bin
export DBSTR='dbi:Oracle:'
export DBUSER='username/pass@abc'
--------below is my perl script-----
Code:
use DBI;use ENV;
my $dbh = DBI->connect($DBSTR, $DBUSER, '', { AutoCommit => 0 } ) 
my $sth = $dbh->prepare( "--some statement; END;" ) 
$sth->execute() 
$sth->finish();
----- The error message i got is ------
DBI connect('','username/pass@abc',...) failed: Error while trying to retrieve
text for error ORA-12154 (DBD ERROR: OCIServerAttach) at myscript.pl line 20
Can't call method "prepare" without a package or object reference at myscript.pl line 21.

#ERROR : Error while trying to retrieve text for error ORA-12154 (DBD ERROR:
OCIServerAttach).
Reply With Quote
Forum Sponsor
  #2  
Old 05-30-2006
Playing with Ubuntu Now!
 

Join Date: Oct 2005
Location: Chennai
Posts: 364
why not this

Why dont you run the script as
. .export.sh
from your .profile file. Then your current shell will have this parameters set. Or if it should be visible to all users put the variable declarations in /etc/profile file.
Reply With Quote
  #3  
Old 05-31-2006
Registered User
 

Join Date: Jan 2006
Posts: 126
Hi ranj@chn,

thank you for your reply. It was a silly mistake. Some of my paths were invalid. I amended the paths, and it could work.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0