Hi folks!

I started working on a small web application that shows reports based on data in a Sybase database.

The application will run on Linux or Solaris, but development is on win32 ( :-( ) for the moment.

When the first script was ready, I tested it on the commandline. Easy piece thanks to CGI.
Ok, time to have it served by Apache: Server Error!

Ahh! Apache thinks it is clever not to pass environment variables to cgi scripts and that's perfectly ok! But I need the SYBASE variable.
Ok, there's the old hack: Place a BEGIN block at the start of the script, set the SYBASE variable in it, and everything's fine.

So I thought, but it didn't work.

I unset the SYBASE variable in a command window and stripped down the script to the smallest working piece and got this to prove the failure:

#!/perl/bin/perl -w BEGIN { $ENV{SYBASE} = 'c:\w03g\sybase\r120500'; } use strict; use warnings; use DBI; system('echo %SYBASE%'); my $dbh = DBI->connect('dbi:Sybase:server=myserver', 'user', 'password' ) or die "could not connect"; # die message cut down here for shortness.
This yields the error:

The context allocation routine failed when it tried to load localizati +on files!!<br> One or more following problems may caused the failure<p> Your sybase home directory is as. Check the environment variable SYBAS +E if it is not the one you want!<br> Cannot access file as\ini\objectid.dat<br> install_driver(Sybase) failed: DBD::Sybase initialize: cs_ctx_alloc() +failed at C:/Perl/lib/DynaLoader.pm line 225.<br> Compilation failed in require at (eval 1) line 3.

This is on WinNT SP6, ActiveState Perl 5.6.1 Build 626. DBD::Sybase 0.91

I knew that the BEGIN hack was working on Linux. Being too lazy to start the Linux box and the Sybase server on it, I tried the script on a Sun box running Solaris 2.8.

I unset the SYBASE variable, started the script and everything was fine.

So why doesn't the BEGIN hack work on win32?

p.s.: I managed to convince Apache to pass the SYBASE variable with 'PassEnv SYBASE' in the config file.


In reply to DBD::Sybase and win32 by busunsl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.