in reply to How do I run .pl script from Unix command line, and pass CGI variables to it?

Not that I have an answer, but I would tackle this by placing debug statements in your cgi right before each execute. If you print, to stderr, the sql statement and the bind values, you can then inspect the apache (or whatever web server) error log for the actual sql that is causing problems. Once you've isolated the actual sql, check it out via isql or sqsh to see if it really is a problem on the database server end (the error statement makes me think the database server is having problems - but who knows, you could be sending it faulty sql).

On another note, check out the DBI and DBD documentation for a slightly better approach on executing sql. I prefer setting the RaiseError flag and then wrapping the actual executes in evals. That way the driver will not spill out error messages that will cause your webserver to barf - but you will have enough info to know what to do:

my $dbh = DBI->connect( "dbi:Sybase:database=xxx", "user", "pass", { RaiseError => 1 } ); eval { my $sth = $dbh->prepare( $sql ); $sth->execute(); ... }; if( $@ ) { print STDERR "An error occurred: $@\n"; } else { print "All is right\n"; }

-derby

  • Comment on Re: How do I run .pl script from Unix command line, and pass CGI variables to it?
  • Download Code

Replies are listed 'Best First'.
Re: Re: How do I run .pl script from Unix command line, and pass CGI variables to it?
by Lori713 (Pilgrim) on Dec 15, 2003 at 16:49 UTC
    Thanks for the pointers. I'm especially interested in ways to test my SQL statements. SQL (along with Perl, HTML, Unix stuff, etc.) is brand new to me. Right now, I have the SQL printing out at the bottom of the web page, just so I can look at what it's really generating. It's ugly, but helps a little bit. ;-)

    Lori