Gossamer Forum
Home : Products : DBMan : Customization :

Accessing one db-file from more than one server

Quote Reply
Accessing one db-file from more than one server
I would like to extend the use of one of my dbman databases (a database containing info on all kinds on happenings in the near futures in the sphere of philosophy) by giving specific others acces to the information in the db-file to integrate the information found therein into their own website without having to reside on the scripts residing on our server.
One possibility would be to establish a client/server link to the db-file, but I don't know how to do this.
Another option would be to have one master db-file and multiple copies elsewhere, which are synchronized when necessary. In that case the master db-file should be copied from one server to a physically remote other server. This whould be done by either a client/server link (via sockets) or an ftp-link between the two servers. Again: I don't know how to establish this exactly.

There might however be someone out there who already has figured this out, so I would be very glad if someone came up with suggestions for a mod for these purposes.

Regards

Bram Bos

Quote Reply
Re: Accessing one db-file from more than one server In reply to
Read up on Net::FTP via http://www.cpan.org and http://www.perl.com.

Regards,

Eliot Lee
Quote Reply
Re: Accessing one db-file from more than one server In reply to
Yeah you could add some simple code to the script to get the database from your server, either by then ftp'ing into your server to get the database once a week or whatever, or by you ftp'ing the database to them, using Net::FTP as Eliot said.

eg...

Code:
use Net::FTP;
my $server = "http://www.theirs.com/";
my $data = "/path/to/database.db";
my $u = "USERNAME";
my $p = "PASSWORD";
$ftp = Net::FTP->new("$server") || die "Could not connect to $server : $!";
$ftp->login("$u","$p") || die "Could not login : $!";
$ftp->cd("/some/path") || die "Couldn't cd to /some/path : $!";
$ftp->put("$data") || die "Could not upload $data : $!";
$ftp->quit;
Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Accessing one db-file from more than one serve In reply to
Thanks, AnthroRules and PaulWilson!

But this ftp-solution implies entering my password into a script that's going to run on another server, while I was thinking: the .db file is world-readable by default, isn't it? So there should be another way to access the data in the .db file without having to *code* my login and password for the master-site in a script on another server, wouldn't it?

Bram

Quote Reply
Re: Accessing one db-file from more than one serve In reply to
Not if another server wants to use your database. Unless you want to make it readable to everyone.

If you have the ability to set up another FTP user then you could put a copy of your database in a nother location for tohers to get at - they would need a password so it would stop anyone seeing it but they could then login using the code above but could only have access to that particular directory.


Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Accessing one db-file from more than one serve In reply to
Apparently I don't understand fully the quintessence of unix, Paul. Is it naive to conclude from the world-readability of the .db file (chmod 775) that it is readable by the world?

The info in the database is public. What if I put a standard copy of the .db file in the public html part of my site? In that case it should be possible to automate a copying process without the need of providing a password, wouldn't it?

Quote Reply
Re: Accessing one db-file from more than one serve In reply to
If you don't mind anyone being able to see your database then putting it in a public place is fine but they could only copy it using Net::FTP if it was available though an anonymous ftp account...unlesss I'm forgetting something.

The only other way to copy it would probably be with LWP::Simple;

Code:
use LWP::Simple;
@database = get($url_of_database);
Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Accessing one db-file from more than one serve In reply to
Thanks Paul. Regrettably, my ISP doen't have the LWP or the Net libraries installed. I'm giving up... :-(

Bram