Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Sheree Hemphill" <sah18 at po dot cwru dot edu>
Subject: RE: Using sybperl with cgi
Date: Feb 16 1999 5:47PM

Well, I am getting closer.  I added the sybase environment variable that you
mentioned in your response, however I am still getting a generic "Server
Error" message on this script.  It doesn't like something about my foreach
loop, when I cycle through the results (again, this is identical to the one
that works as a shell script).  I'm not sure if I'm having a sybperl problem
or a cgi problem at this point.

Here is my modified code:

#!/usr/local/bin/perl -w

	$ENV{SYBASE} = "/usr/sybase";

use CGI qw(:standard);
use Sybase::CTlib;

my $dbh = new Sybase::CTlib 'sa', 'password', 'helix';
$dbh->ct_sql("use htn");

my $data = $dbh->ct_sql("select * from BIA");
my $TITLE;
my $cur;

$TITLE = "BIA Results";
print header, start_html($TITLE), h1($TITLE);
print hr;
foreach $row (@$data) {
	print "$$row[0] - $$row[1] - $$row[2] - $$row[3] - $$row[4] - $$row[5] -
$$row[6] - $$row[7] - $$row[8] - $$row[9] - $$row[10] - $$row[11]\n";
print hr;
print end_html;

> -----Original Message-----
> From:
> []On Behalf Of Michael Peppler
> Sent: Tuesday, February 16, 1999 11:22 AM
> To: SybPerl Discussion List
> Subject: Using sybperl with cgi
> >>>>> "Sheree" == Sheree Hemphill  writes:
> Sheree> I wrote the following program, which accesses the data
> Sheree> correctly when run from the command prompt:
> What is your $SYBASE environment variable set to when you run your
> script from the shell?
> For a CGI script you need to set this environment variable too. This
> can either be done in the script, or via the httpd server's config
> files.
> To set the env. variable in the script you need to do this:
> #!/usr/local/bin/perl -w
>    $ENV{SYBASE} = "/where/I/have/sybase";
> }
> use strict;
> use Sybase::CTlib;
> use CGI qw(:standard);
> my $dbh = new Sybase::CTlib ...
> etc...
> I don't know the commands to set the env. variables in all the various
> httpd servers, but for Apache you can add this to the httpd.conf file:
> SetEnv SYBASE /where/I/have/sybase
> and restart the server. Now all scripts will have the $SYBASE
> env. variable set correctly.
> Of course you should replace /where/I/have/sybase with the real path
> to your Sybase installation :-)
> Michael
> --
> Michael Peppler         -||-  Data Migrations Inc.
>       -||-
> Int. Sybase User Group  -||-
> Sybase on Linux mailing list: