PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: $SYBASE not recognized
Date: Jul 23 2002 3:07PM

On Tue, 2002-07-23 at 07:52, abrown@mmm.com wrote:
> I'm not sure if this is better suited for the perl mailing list or the
> Sybperl mailing list, but here goes:

This is the appropriate place.

> #!/usr/bin/perl
> 
> $ENV{"SYBASE"}="/opt/sybase";

> $ENV{"LD_LIBRARY_PATH"}="$ENV{SYBASE}/OCS/lib";

> use Sybase::CTlib;

A couple of issues here.

First - a perl "use" command is run *before* the rest of the script - so
although you are setting $ENV{SYBASE} to something before the "use"
command in your script the assignment is only executed *after* the "use"
commands have been executed.

To have the %ENV value set before the "use" statement executes you have
to use a BEGIN block:

BEGIN {
   $ENV{SYBASE} = "/opt/sybase-12.5";
};

use Sybase::CTlib;

Next - you can't set LD_LIBRARY_PATH for the running process. It just
won't take, no matter how hard you try.... You can only set this env.
variable for children of the current process.

On linux LD_LIBRARY_PATH should not be needed - you should have an entry
on /etc/ld.so.conf that points to /opt/sybase-12.5/OCS/lib, and the
dynamic loaded (ld.so) should use that value when looking for shared
libraries.

Now as an aside - you are saying that this is for CGI scripts, right?

If you are using Apache you can sidestep the entire ENV variable issue
by adding entries to Apache's httpd.conf file:

SetEnv SYBASE=/opt/sybase-12.5

Now every CGI script will have the SYBASE env. variable set correctly.

Michael
-- 
Michael Peppler / mpeppler@peppler.org / http://www.mbay.net/~mpeppler
mpeppler@zetatools.com / ZetaTools, Inc / http://www.zetatools.com
ZetaTools: Call perl functions as Sybase stored procedures!