coffee wrote:
coffee wrote:
[snip]

1)
script one ::
   send request to script two with something like ?grab=variable
2)
script two ::
   sees that they want the value of 'variable' and sends
   it back to script one with something like ?variable=monkey
3)
script one ::
       parses that reply from script two and uses the data
       $variable = $input_from_script_two{'variable'};
       print "You are a $variable";

[snip]

I'm not clear what your scripts have to do with LWP.  You could easily
implement this with Net::Socket or something if all you want is two
scripts to communicate with each other over the network.
I'm willing to try anything! :-)They have to communicate over the
internet each on two different servers in two different cities.


Can you be more specific as to what you are trying to accomplish?

Sure thing.
I have data stored in a mysql database.
I have a script that can access that database and set certain variables to
their appropriate values.

Instead of giving every script I want to use those variables all of that
code and more imortantly access to the database itself. I need to be able to
send it a request somehow for a specific variable, have it set that variable
form the database, and return it to the original requesting script.

Maybe LWP isn't what I need, I got the idea from looking over the paypal ipn
system and seeing their use of LWP for a similar idea.

If I was to write it out as I'd script it I would think it would be similar
to this obviously I'm going to do more than just pritn it out but I don't
want to :

#!/usr/bin/perl

$url = "http://domain.com/get_data_from_db.cgi";;

#send request, how exaclty I don't know

$url?grab=first_name,last_name

# $url would get this request, set the data and send back key,value pairs

$result = ????
# $result would look like first_name=Joe&last_name=Mama

#parse $result into a hash or vars or whatever  here

print "Hello $input{'first_name'} $input{'last_name'}";

Does that explain a little better what I need to do?

Thanks

Dan


You need to look at SOAP::Lite, I think. That would be one way to accomplish this. Since you don't really need to interact with a web page, LWP probably isn't necessary. SOAP is web services (or you could look at XML-RPC) and this is exactly the kind of problem it was designed for. You have a generic "service" script somewher that handles the database connectivity which exports an API for adding a variable or retieving it. Additionally, SOAP is designed so that you can secure the transaction so that not just any script to could add things to your DB.

If you are really sure you don't need security and the "genericness" of SOAP, you might look at just setting up a simple TCP daemon that listens for connections from your client scripts. This means you would have to invent the higher level protocol yourself (parsing out the requests from the data, formating your replies, etc). It also would be pretty insecure if you are using it over a network.

I have to admit that I haven't done any development with SOAP but I know this is the kind of problem that it was invented for.

The other issue, though, is do you really want to abstract away the DB connection stuff from each script. The reason to have all that present in each script is so that you don't have a huge gaping hole in your DB access model. Perhaps if you abstracted your DB access into an object that you 'use'd in all your scripts, you could get the benefits of having all the db access stuff in just one place but still have the actual security of only having no intermediaries between your script that needs the DB info and the DB itself.

Hard to say what the best trade offs are.

Hope this helps.

--
In Reach Technology: http://inreachtech.net/

Robert G. Werner
[EMAIL PROTECTED]

Tel: 559.304.5122

Reply via email to