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: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Calling sybperl from within an HTML file
Date: Dec 9 1997 1:32AM

Teresa Fiske wrote:
> At the County of San Diego we are exploring the possibility of using
> sybperl. Currently it is executing and accessing data fine from the UNIX
> command line (SGI IRIX 6.4). However, how do you execute/invoke perl
> from an HTML file?
> Thanks in advance for any help you can offer.

What you're trying to do is called CGI scripting.

You should get a good book on writing CGI scripts, but the basic
minimal structure of a perl/sybperl CGI script is something like this:

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

    $ENV{SYBASE} = "/your/sybase/installation/directory";

use strict;
use CGI;
use Sybase::DBlib;
use SybWWW;    # Send Sybase error messages to the browser

my $query = new CGI;
print $query->header;    # print "Content-Type: text/html"
print $query->start_html;

my $dbh = new Sybase::DBlib "userID", "pwd", "server";
	# Change params above as needed

$dbh->dbcmd("select * from sysusers");

print "

Output from sysusers:

\n"; $dbh->dbsqlexec; print "\n"; while($dbh->dbresults != NO_MORE_RESULTS) { my @dat; print "\n"; while(@dat = $dbh->dbnextrow) { foreach (@dat) { print " } print "\n\n"; } } print "
"; print $query->end_html; exit(0); __END__ To execute this script it has to be placed in an appropriate directory where the http server will find it (usually somewhere under the /cgi-bin/ tree) and then loaded as a normal url. Hope this helps! Michael -- Michael Peppler -||- Data Migrations Inc. -||-