Re: A simple client/server problem

2004-07-31 Thread Dan Timis
Thanks Bob,
I looked at LWP and it looks great.  I will keep it in mind for other 
applications.

I should have been more clear about what I meant by simple.  I have 
100+ clients that need to run this script, and I cannot install any 
kind of significant Perl modules on them.

I found a file called geturl11.pl 
(http://www.jmarshall.com/easy/http/geturl11.pl.txt) that is pretty 
much self contained (it uses Socket, but that's already installed).  
geturl11.pl opens a socket, builds the HTTP request, parses the reply 
and saves the data to a file.  All I had to do is add Content-length: 
and the contents of my request.xml file to GET.

Thanks,
Dan Timis
Muse Research, Inc.
On Friday, July 30, 2004, at 05:26 AM, Bob Showalter wrote:
Dan Timis wrote:
Hi everyone,
I am very new to Perl.  I need two perl scripts, one would run on a
client, the
other would run on a server.
...
I think I can also handle most of the client side.  What I don't know
how to do
is open a two way connection with the server.  Do I do something like
this:
 open CONNECTION http://www.myserver.com/cgi-bin/generate-reply;
Where can I find some example code?
Use the LWP family of modules for this. It's designed for creating HTTP
clients (and servers, for that matter).
   http://search.cpan.org/~gaas/libwww-perl-5.800/


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: A simple client/server problem

2004-07-31 Thread Dan Timis
On Saturday, July 31, 2004, at 07:01 PM, Randal L. Schwartz wrote:
Dan == Dan Timis [EMAIL PROTECTED] writes:
Dan I should have been more clear about what I meant by simple.  I 
have
Dan 100+ clients that need to run this script, and I cannot install 
any
Dan kind of significant Perl modules on them.

See PAR, then.
Thanks.  Looks great.
Dan
Cannot install is not a valid excuse.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 
0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl 
training!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



A simple client/server problem

2004-07-29 Thread Dan Timis
Hi everyone,
I am very new to Perl.  I need two perl scripts, one would run on a 
client, the
other would run on a server.

The perl script on the client machine runs an application.  The 
application
creates a file called request.xml  The perl script reads the file, 
and sends
it to the server.

A cgi script on the server reads the file and saves it as request.xml 
then
runs another application.  The application reads request.xml and 
creates
reply.xml.  The server perl script reads reply.xml and sends it 
back to the
client.

The client reads the data from the server and saves it as reply.xml
I looked all over for some example code.  I found lots of examples 
about how to
upload a file to the server, but they are all about the server part, 
and how to
generate html that would let a user choose a file to upload.  I could 
not find
anything about how a client would connect to a server, send some data, 
and then
read some data back.

I think I have figured out the server part.  It would be something like 
this:

# read request from client and save it in a file
read(STDIN, my $request, $ENV{'CONTENT_LENGTH'});
open REQUEST_FILE,  . request.xml or
croak Cannot create REQUEST_FILE: $!;
print REQUEST_FILE $request;
close REQUEST_FILE;
# save old stdout, redirect stdout to a temp file
open my $oldout, STDOUT or
croak Can't duplicate STDOUT: $!;
open STDOUT,  . temp.txt or
croak Can't redirect STDOUT: $!;
# run the create-reply application,
# close stdout, and restore the saved stdout
systemcreate-reply;
close STDOUT;
open STDOUT, , $oldout or
croak Can't restore old STDOUT: $!;
# read the reply.xml file
open REPLY_FILE, reply.xml or
croak Cannot open REPLY_FILE: $!;
(undef, undef, undef, undef, undef, undef, undef, my $replySize, 
undef,
undef, undef, undef, undef ) = stat REPLY_FILE;
read(REPLY_FILE, my $reply, $replysize);
close REPLY_FILE;

# send reply.xml to the client
my $cgi = new CGI;
print $cgi-header(-type='text/xml');
print $reply;
# Clean up
unlink request.xml;
unlink reply.xml;
unlink temp.txt;
I think I can also handle most of the client side.  What I don't know 
how to do
is open a two way connection with the server.  Do I do something like 
this:

open CONNECTION http://www.myserver.com/cgi-bin/generate-reply;
Where can I find some example code?
Thanks,
Dan Timis
Muse Research, Inc.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response