Connect DB2 environment setting problem

O

oillai

Hi,

I write a perl program to connect to a remote DB2 database to generate
daily report.

I execute the program by command line is OK, but executed by crontab
is failed.

The program connection section:
$uid="username";
$pwd="password;
$dsn = "dbi:DB2:DATABASE=WAREHOUS";
$warehouse_dbh = DBI->connect($dsn, $uid, $pwd) || die "Connection
failed with error: $DBI::errstr";
============================================================================
The error message is following.
Connection failed with error: Total Environment allocation failure!
Did you set up your DB2 client environment?
 
A

anno4000

Hi,

I write a perl program to connect to a remote DB2 database to generate
daily report.

I execute the program by command line is OK, but executed by crontab
is failed.

The program connection section:
$uid="username";
$pwd="password;
$dsn = "dbi:DB2:DATABASE=WAREHOUS";
$warehouse_dbh = DBI->connect($dsn, $uid, $pwd) || die "Connection
failed with error: $DBI::errstr";
============================================================================
The error message is following.
Connection failed with error: Total Environment allocation failure!
Did you set up your DB2 client environment?

Well, did you?

Apparently DB2 uses a number of environment variables that must be set
up correctly. That seems to be the case in your interactive
environment, but not in cron, which is nothing unusual.

Find out what the difference in environment variables is between cron
and your shell (a cron job that calls "printenv" should do), then set
the necessary variables in the cron job.

Anno
 
C

c00p

Hi,

I write a perl program to connect to a remote DB2 database to generate
daily report.

I execute the program by command line is OK, but executed by crontab
is failed.

The program connection section:
$uid="username";
$pwd="password;
$dsn = "dbi:DB2:DATABASE=WAREHOUS";
$warehouse_dbh = DBI->connect($dsn, $uid, $pwd) || die "Connection
failed with error: $DBI::errstr";
============================================================================
The error message is following.
Connection failed with error: Total Environment allocation failure!
Did you set up your DB2 client environment?

When we run any shell scripts against db2 we have to reference
db2profile for exactly that reason...a simple shell wrapper that runs
db2profile, then your perl program would do the trick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top