RE: DBI->Connect returning UNDEF in cgi but not in standalone pro g

From: Graeme St. Clair (Graeme.St.Clair_at_hds.com)
Date: 03/23/05


To: dbi-users@perl.org
Date: Tue, 22 Mar 2005 17:41:04 -0800

I got this error just the other day. I had transcribed the following from a
script where it worked to another script - and screwed up by just typing
"dbi:Oracle:host" iso "$dbi:Oracle:$host". But this connection call
definitely works to an 8.1.7 sys. In other words, "host" was not a valid
target d-b whereas "FRED.JOE.COM" is (at my location!).

  $host = q{FRED.JOE.COM};
  $dbh = DBI->connect("dbi:Oracle:$host", $uid, $pw)
     or die qq{Unable to connect to $host:<br/>$DBI::errstr\n};

HTH, GStC.

-----Original Message-----
From: Sunil A.V. [mailto:sunilav@rediffmail.com]
Sent: Tuesday, March 22, 2005 3:22 PM
To: dbi-users@perl.org
Cc: Reidy,Ron; Bill.Costa@unh.edu; Tim.Bunce@pobox.com
Subject: Re: RE: RE: DBI->Connect returning UNDEF in cgi but not in
standalone prog

As per Reidy, I printed $DBI::errstr and it turned out to be
"Error: ORA-12154: TNS:could not resolve service name (DBD ERROR:
OCIServerAttach) at myapp_utility.pm"

This probably means Oracle SID or instance name which is 'ledmyapp' is not
being recognized and is not there in tnsnames.ora But I confimed that
tnsnames.ora has ledmyapp. Thats why standalone perl program worked from
command line.

So as per Ron and Bill, I also agree that environment variables might be
incorrect. So I explicitly added $ENV{'ORACLE_HOME'} =
'/opt/oracle/product/9.2.0.6.0_64c';
$ENV{'LD_LIBRARY_PATH'} = '/opt/oracle/product/9.2.0.6.0_64c/lib';
$ENV{'ORACLE_SID'} = 'ledmyapp';
$ENV{'PATH'} =
$ENV{'PATH'}.":/opt/perl5/bin:/opt/oracle/product/9.2.0.6.0_64c/bin";

I printed them also to confirm that additions are being recognized. It is
BUT STILL I AM GETTING THE SAME ERROR.
Do you think any other env variables might be missing OR is there a
different way to set env vars for iPlanet web server perl cgi progs?

On Wed, 23 Mar 2005 Bill.Costa@unh.edu wrote :
>
> Ron.Reidy@arraybiopharma.com recently wrote (in part):
>
> > The fact your code executes from the command line and not the web
> > server indicates either a permissions problme or an environment
> > problem.
>
> I'll second that environment problem observation. When something
> works from the command line but not as a CGI, that's one of the
> first things I check. Here's an ugly Perl script that might
> be of use in comparing the two environments.
>
>
> ...BC
>
>--
>+----------------------------[ Bill.Costa@UNH.EDU ]---+
>| Bill Costa |
>| CIS/TCS -- 1 Leavitt Lane PHONE: +1-603-862-3056 | No good deed...
>| University of New Hampshire | goes unpunished.
>| Durham, NH 03824 USA |
>| |
>+-----------------[ http://pubpages.unh.edu/~wfc/ ]---+



Relevant Pages

  • Re: Possible to define a variable for only certain directories?
    ... allows such customizations upon the environment on a per- ... this is useful only if the user or script ... configuration files, environment variables, command line options, and ... commands to the CDE Window Manager from a shell ...
    (comp.unix.shell)
  • Obtaining complete Unix command line that evoked script as string
    ... If there is a more appropriate list for this, let me know; the other perl lists I've seen seem to specialised for this. ... Note this is not just the arguments of the call to the script, but everything including pipes and redirects, etc., e.g. ... Ideally the perl interpreter would grab the complete command line as its evoked and I'd access this via a variable. ...
    (perl.beginners)
  • Re: user id validation
    ... I have not tried like that but I feel it can be done because the environment ... Rajnikant Jachak | Software Engg | Persistent Systems Limited ... I am just wondering how to validate a user who is using the script?? ... there specific perl command for that? ...
    (perl.beginners)
  • Re: Displaying a users group memberships
    ... The user's username is passed to the script via the command line and captured with ARGV. ... I want to determine the group memberships (much like executing `groups` from the command line) and run those through a loop for processing. ... I'm very new to Perl so maybe I'm just looking for the wrong terms or something. ... The format of the command is simple: `test.pl username`, where username is a real username on the system in question. ...
    (perl.beginners)
  • Re: "register" (in perl scripts)
    ... scripted gimp. ... This is a Perl problem, not a GIMP problem so you would probably ... it looks to me like you're trying to execute a command ... By the way, your script doesn't appear to use any CGI, etc. - at ...
    (comp.graphics.apps.gimp)