talexb has asked for the wisdom of the Perl Monks concerning the following question:

I was interested is using DBI:ProxyServer and DBD::Proxy in combination to access a remote SQLite database, so I coded up what I thought was a perfectly harmless test script to act as a server.

#!/usr/bin/perl -w # Server component of SQLite client/server prototype. use DBI::ProxyServer; { DBI::ProxyServer::main({ clients => [ '192.168.0.115' ], debug => 1, localaddr => '192.168.0.124', localport => 16000, logfile => '/tmp/Server.log', mode => 'fork', pidfile => '/tmp/Server.pid', }, @ARGV); }

Running this produced nothing in the log file (either as a regular user or as root), and netstat -at | grep -i listen did not show me that anything was listening on port 16000.

I haven't defined any clients, since this is just a test setup -- it's wide open (on my LAN, which is safe enough), and I haven't done anything to suggest which databsae this is going to connect to. Has anyone here used this module? Am I making some egregious error?

PS in case anyone else wants to try this module out, note that you'll also need to insatll Net::Daemon and RPC::PIServer, the latter of which is confusingly called PlRPC.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re: DBI::ProxyServer question
by rhesa (Vicar) on Oct 01, 2007 at 21:16 UTC
    It's been a long time ago, but I used to use the supplied command line tool, dbiproxy. The source of that script is basically DBI::ProxyServer::main(@ARGV);. That seems to indicate what DBI::ProxyServer suggests too, namely that you're supposed to supply it with a list of options, which will be parsed by Getopt::Long.

    Based on this, I believe your script should drop the {}s around the options.

      Sorry for not actually testing what I wrote earlier. I've given it some more attention, and I've come to the conclusion that you also need to prefix the option names with a '-'.

      This script:

      #!/usr/bin/perl -w # Server component of SQLite client/server prototype. use DBI::ProxyServer; { DBI::ProxyServer::main( # clients => [ '192.168.0.115' ], -debug => 1, -localport => 16000, -logfile => '/tmp/Server.log', -mode => 'fork', -pidfile => '/tmp/Server.pid', , @ARGV); }
      produces the following output:
      Use of uninitialized value in string eq at /opt/perl/lib/site_perl/5.8 +.8/i686-linux/DBI/ProxyServer.pm line 99. Tue Oct 2 12:21:27 2007 debug, Server starting in operation mode fork Tue Oct 2 12:21:27 2007 notice, Server starting Tue Oct 2 12:21:27 2007 debug, Writing PID to /tmp/Server.pid
      Furthermore, netstat shows it's listening on port 16000:
      $ netstat -natp | grep LIST tcp 0 0 0.0.0.0:16000 0.0.0.0:* LISTEN 2624/perl
      I suspect you'll need to read the docs for the exact specs for the clients option, as I saw it said the elements are supposed to be hashrefs. I didn't bother testing that.

      HTH,
      Rhesa