From: Alan A. <al...@ru...> - 2003-01-30 04:47:48
|
Howard, I just ran across a similar thing writing a Perl script to do something specific for me. There are two logic flaws in the refdbc client. I hadn't piped up about them yet because I haven't formalized the suggested fixes. Since you're asking, I'll post them here and maybe Markus can integrate the changes or come up with more suitable suggestions. There are two difficulties with trying to run refdbc from within a CGI application (this includes PHP). First, refdbc is compiled with CGI support builtin, and it tests the environment to determine whether it is running as a CGI application or a standalone application. This test is simply the existence of the REQUEST_METHOD environment variable. Since we are running refdbc from within another CGI application this variable exists, so refdbc assumes it is running in CGI mode. This test seems to override the -C commandline option (didn't really take the time to find out if this is exactly true). My solution was to #undef REFDB_CGI at the top of refdbc.c and recompile refdbc to create a "nocgi" version. I named it refdbc-nocgi and copied it into /usr/local/bin. The second problem is that refdbc attempts to call fgets in several places regardless of whether it is run in "batch" mode. Attached is a diff file which should show you where fixes are needed, but you'll have to fight through some garbage changes that I made for debugging. In two or three places there is a test like if (n_read_file || n_read_stdin) { If this test succeeds, then fgets is called (not directly, but eventually in each case--I'm not exactly sure what difficulty this causes, but I'm guessing the web server hasn't provided STDOUT or something--in any case, the fgets fails). If the test fails, then the string sent to the refdbd server is not completed and you get the "unknown command" error in the log. I changed these lines to also test for batch mode: if ((n_read_file || n_read_stdin) && !n_batchmode) { In this case, it does not call fgets AND the command string is correctly created and sent to refdbd. I hope this makes sense, and I hope Markus doesn't take offense to the "logic" comment above. I think RefDB is a great tool, and I use it everyday. Hope this helps. Al > -----Original Message----- > From: ref...@li... > [mailto:ref...@li...]On Behalf Of Howard > Schultens > Sent: Tuesday, January 28, 2003 8:45 AM > To: ref...@li... > Subject: [Refdb-users] refdbc and php4 > > > Hello > > RefDB works perfectly on my system, and my LAMP system works > fine, but I need to use refdbc from PHP. I can't use the > cgi version. I can't get this to work. If I try the command > > /usr/local/bin/refdbc -C getref :AU:=richter > > from the command line, it works correctly and gives me 13 > references. If I try it in a shell script, it also works. > But if I try calling this command with the PHP functions 'system' > 'exec' 'passthru', etc, or with a pipe, it returns an > error. The log file for the refdbd daemon has this: > > 6:pid=3856:Tue Jan 28 11:49:17 2003:adding client on fd 6 > 6:pid=3856:Tue Jan 28 11:49:17 2003:server waiting n_max_fd=6 > 6:pid=12484:Tue Jan 28 11:49:17 2003:serving client on fd 6 with > protocol version 0 > 4:pid=12484:Tue Jan 28 11:49:17 2003:unknown command > 4:pid=12484:Tue Jan 28 11:49:17 2003:no positive ack from client > 6:pid=12484:Tue Jan 28 11:49:17 2003:child finished client on fd 6 > 6:pid=3856:Tue Jan 28 11:49:17 2003:parent removing client on fd 6 > 6:pid=3856:Tue Jan 28 11:49:17 2003:server waiting n_max_fd=5 > 6:pid=3856:Tue Jan 28 11:49:17 2003:child exited with code 1 > > If I set the log level to 'debug' (-l7) in refdbc, I get this > in the log file when calling from PHP: > > 7:pid=15100:Tue Jan 28 15:20:35 2003:getref :AU:=richter > > If I call the program directly (or from a shell) this > is > > 7:pid=14990:Tue Jan 28 15:14:20 2003:getref ":AU:=richter" -u zmpg -w > 121069035118125116045057 -d ZMPGlit -R > /home/local/ZMPG/zmpg/Documents/PDFs -G /usr/local/share/refdb/css/refdb.css > > In other words, when I call refdbc from PHP, it ignores both > the configuration file and most of the command line parameters. > > What are the special tricks for getting refdbc to work from PHP? > > Thanks, > > -- Howard > > -------------------------------------------------------------------- > Dipl.-Phys. Howard Schultens Tel: +49 551 39-5914 > Zentrum Physiologie FAX: +49 551 39-5923 > Humboldtallee 23 > 37073 Goettingen mailto:howard at ukps.gwdg.de > Germany http://www.neuro-physiol.med.uni-goettingen.de > -------------------------------------------------------------------- > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > _______________________________________________ > Refdb-users mailing list > Ref...@li... > https://lists.sourceforge.net/lists/listinfo/refdb-users > > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 > |