|
From: Nick B. <Nic...@po...> - 2001-12-20 12:33:15
|
I figured out the "Socket command type N unknown" problem. Here's
what is going on:
For some reason, my Apache (2.0.28) runs CGI with stderr closed. So
when Perl opens a connection to Postgres, it gets file descriptor 2,
which would ordinarily be stderr. The "create table chart" command
generates this notice from Postgres:
NOTICE: CREATE TABLE/UNIQUE will create implicit index 'chart_accno_key' for table 'chart'
Either DBI or DBD::Pg decides that the best thing to do with a message
like this is to write it out on STDERR. But STDERR now points back at
Postgres, so this message goes to Postgres, which doesn't like it at
all, and says so:
FATAL 1: Socket command type N unknown
(the 'N' is just the first character of the message).
Here's a cut-down database creation test:
#!/usr/bin/perl
use DBI;
sub dberror {
print "<h2>Error!</h2><p><b>";
print DBI::errstr;
print "</b></p></body></html>";
die(DBI::errstr);
}
print "Content-Type: text/html\n\n\n";
print "<html><head></head><body>";
$dbh = DBI->connect("dbi:Pg:dbname=template1", "nb", "") || dberror();
$dbh->do("CREATE DATABASE slt") || dberror();
$dbh->disconnect;
$dbh = DBI->connect("dbi:Pg:dbname=slt", "nb", "");
open FH, "sql/Pg-tables.sql";
$query = "";
while (<FH>) {
next if (/^(--|\s*$)/);
$query .= $_;
if (/;\s*$/) {
$dbh->do($query) || dberror();
$query = "";
}
}
close FH;
$dbh->disconnect;
print "</body></html>";
This works when run from the shell, but as CGI or run from the shell
with stderr closed (using "2<&-" in /bin/sh), I get the same fatal
error.
My work-around is to add this code at the head of the script:
if (! -w STDERR) {
open (STDERR, ">/dev/null") || die("Can't open stderr to /dev/null");
}
I'm not sure where I should add code like this to sql-ledger.
Nick B
|
|
From: Dieter S. <dsi...@sq...> - 2001-12-20 16:06:15
|
Change the Pg-tables.sql file. remove the unique keyword from the CREATE TABLE chart ( accno int UNIQUE, change it to accno int, and add CREATE UNIQUE INDEX chart_accno_key on chart using btree (accno int4_ops); at the very end. Should you run into any more STDERR errors than put your workaround into am.pl and login.pl (these are the ones in the root directory) Dieter Simader http://www.sql-ledger.org (780) 472-8161 DWS Systems Inc. Accounting Software Fax: 478-5281 =========== On a clear disk you can seek forever =========== On Thu, 20 Dec 2001, Nick Barnes wrote: > I figured out the "Socket command type N unknown" problem. Here's > what is going on: > > For some reason, my Apache (2.0.28) runs CGI with stderr closed. So > when Perl opens a connection to Postgres, it gets file descriptor 2, > which would ordinarily be stderr. The "create table chart" command > generates this notice from Postgres: > > NOTICE: CREATE TABLE/UNIQUE will create implicit index 'chart_accno_key' for table 'chart' > > Either DBI or DBD::Pg decides that the best thing to do with a message > like this is to write it out on STDERR. But STDERR now points back at > Postgres, so this message goes to Postgres, which doesn't like it at > all, and says so: > > FATAL 1: Socket command type N unknown > > (the 'N' is just the first character of the message). > > Here's a cut-down database creation test: > > #!/usr/bin/perl > use DBI; > > sub dberror { > print "<h2>Error!</h2><p><b>"; > print DBI::errstr; > print "</b></p></body></html>"; > die(DBI::errstr); > } > > print "Content-Type: text/html\n\n\n"; > print "<html><head></head><body>"; > $dbh = DBI->connect("dbi:Pg:dbname=template1", "nb", "") || dberror(); > $dbh->do("CREATE DATABASE slt") || dberror(); > $dbh->disconnect; > $dbh = DBI->connect("dbi:Pg:dbname=slt", "nb", ""); > open FH, "sql/Pg-tables.sql"; > $query = ""; > while (<FH>) { > next if (/^(--|\s*$)/); > $query .= $_; > if (/;\s*$/) { > $dbh->do($query) || dberror(); > $query = ""; > } > } > close FH; > $dbh->disconnect; > print "</body></html>"; > > This works when run from the shell, but as CGI or run from the shell > with stderr closed (using "2<&-" in /bin/sh), I get the same fatal > error. > > My work-around is to add this code at the head of the script: > > if (! -w STDERR) { > open (STDERR, ">/dev/null") || die("Can't open stderr to /dev/null"); > } > > I'm not sure where I should add code like this to sql-ledger. > > Nick B > > |
|
From: <gha...@fr...> - 2001-12-20 19:58:25
|
One thing I did when installing SQL-Ledger (and having problems), is to add some perl code to the beginning of that .conf file that gets loaded near the beginning of all the SQL-Ledger modules. Something like: close( STDERR ); open( STDERR, ">>/usr/local/log/sql-ledger.log" ); This results in error messages getting redirected to a log file, instead of going to the web server and possibly causing it to generate errors. Gord |
|
From: Philip R. <p....@li...> - 2001-12-20 20:33:31
|
Hello Dieter, I have two questions: 1.) I got an eMail today from someone who has modules for sales order offers etc, which he thinks could be integrated into sql-ledger. How far away is release 1.8 I'm asking, because if it is to long away we will start working on it ourselves. 2.) How is the PDF output coming? I know it is on the todo list. We would like to start working on it right away and don't start from scratch if someone has already invested some thought and time into this project. We would like to join forces with people who work on it. If nobody has started working on it, maybe you can give us a few hints how you would like to see it implemented so we go into the right direction. Thank you very much. Bye, Philip -- LINET Services Linux im Intra- und InterNet Rebenring 33 Tel.: 0531-280 191 71 38106 Braunschweig Fax: 0531-280 191 72 http://www.linet-services.de mailto:in...@li... |
|
From: Brian J. <bjo...@je...> - 2001-12-20 21:09:16
|
This might help: http://www.easysw.com/htmldoc/ It's a GNU program with source code to convert HTML to PDF (among other things) It isn't in Perl but it can be run from a command line -----Original Message----- From: sql...@li... [mailto:sql...@li...]On Behalf Of Philip Reetz Sent: Thursday, December 20, 2001 3:35 PM To: Dieter Simader Cc: sql...@li... Subject: PDF output Hello Dieter, I have two questions: 1.) I got an eMail today from someone who has modules for sales order offers etc, which he thinks could be integrated into sql-ledger. How far away is release 1.8 I'm asking, because if it is to long away we will start working on it ourselves. 2.) How is the PDF output coming? I know it is on the todo list. We would like to start working on it right away and don't start from scratch if someone has already invested some thought and time into this project. We would like to join forces with people who work on it. If nobody has started working on it, maybe you can give us a few hints how you would like to see it implemented so we go into the right direction. Thank you very much. Bye, Philip -- LINET Services Linux im Intra- und InterNet Rebenring 33 Tel.: 0531-280 191 71 38106 Braunschweig Fax: 0531-280 191 72 http://www.linet-services.de mailto:in...@li... |
|
From: Marvin D. <pe...@be...> - 2001-12-21 02:15:48
|
On Thursday 20 December 2001 16:09, you wrote: > This might help: http://www.easysw.com/htmldoc/ > > It's a GNU program with source code to convert HTML to PDF (among other > things) > > It isn't in Perl but it can be run from a command line Having coded document format conversion utilities for other applications, it seems to me the obvious choice would be to use ImageMagik to do the conversions. The convert utility, that ships with ImageMagik, among other things, will convert HTML to PDF files (As long as you have the ps2pdf utility that ships with ghostscript installed) with little effort. In addition to being able to produce PDF output, you also will have the ability to produce output in other formats: AVS, BIE, BMP, CGM, CYMK, DCX, DIB, DICOM, EPDF, EPI. EPS, FAX+ GIF, GREY, JPEG, MIFF, MPEG, PCD, PCL, PGM, PNG, PS2+, RGB, TIFF, TXT Just to name a few... I would be willing to spend some time creating a module for SQL-Ledger to produce this type of output. Any other takers...?... Just so you know, my perl skill are probably not as strong as others on the list, but I do have pretty good amount of programming experience regarding document conversion and ImageMagik. Best Marvin Dickens |