It is currently Mon, 27 Jun 2022 13:11:19 GMT



 
Author Message
 Generating an HTTP Request From a Script?
Hi,

Does anyone know of a method to generate an HTTP request from a PERL
script (or any other language implementation)?

The idea is to execute a CGI script on a remote machine.

Thank You for your help,

Bill Koss
wk...@kingtech.com



 Tue, 06 Oct 1998 03:00:00 GMT   
 Generating an HTTP Request From a Script?

hi there.

I would suggest using the LOCATION header.

print "Location: /special.html", "\n\n";    
***this moves you to a page

print "Location: http://www.there.com/", "\n\n";
***but this one moves you to a different domain

print "Location: http://www.somewhere.com/finger...@company.com
***and this one runs the finger command (cgi) at somewhere.com

good luck.
dwight



 Tue, 06 Oct 1998 03:00:00 GMT   
 Generating an HTTP Request From a Script?

: Does anyone know of a method to generate an HTTP request from a PERL
: script (or any other language implementation)?
: The idea is to execute a CGI script on a remote machine.

This will run the form.cgi on localhost, with form input of
name= bob, and email=...@here.com

#!/usr/bin/perl -w
use LWP::UserAgent ;
$ua = new LWP::UserAgent ;
$ua->agent("Mozilla/3.0") ;  # Why didn't I hear about this?! ;-)
$req = new HTTP::Request 'POST', 'http://localhost/cgi-bin/form.cgi' ;
$req->content('name=me&email=...@here.com') ; #Filled in form data here
$req->header('Accept' => 'text/html') ;
$res = $ua->request($req) ;
if($res->is_success){
        print $res->content ;
        } else {
        print "Error: " . $res->code ." ". $res->message ;
        }

Danny



 Wed, 07 Oct 1998 03:00:00 GMT   
 Generating an HTTP Request From a Script?
In article <3177F917.1...@kingtech.com>, Bill Koss  <wk...@kingtech.com> wrote:

You just have to open a connection to the server, here's an example using
perl 5 (mainly stolen from the perlipc man page...)

#!/usr/local/bin/perl

use Socket;

$host = 'localhost';
$port = 80;
$request = 'GET /cgi-bin/glimpse';

$iaddr = inet_aton $host                or die "no address for $host ($!)\n";
$paddr = sockaddr_in $port, $iaddr;
$proto = getprotobyname 'tcp'           or die "can't look up 'tcp'\n";

socket S, PF_INET, SOCK_STREAM, $proto  or die "socket failed ($!)\n";
connect S, $paddr                       or die "connect failed ($!)\n";

$oldFh = select S;                      # unbuffer the socket
$| = 1;
select $oldFh;

print S "$request HTTP/1.0\n\n";

while (<S>)
{
  print;

__END__

Hope this helps,

Mike
--
Mike Stok                        | The "`Stok' disclaimers" apply.
s...@pencom.com                  | Pencom Systems Administration (work)
s...@{*filter*}com.net                | {*filter*} Access (play)
http://www.{*filter*}com.net/~stok/   | The inevitable WWW page (?)



 Thu, 08 Oct 1998 03:00:00 GMT   
 Generating an HTTP Request From a Script?
Here's a simple example in boern shell.  It should give you the idea.

#!/bin/sh
telnet ovlov 80 << eof
POST /cgi-bin/bv.cgi/templates HTTP/1.0
Accept: */*
User-Agent: Patrick's cool script
Content-type: application/x-www-form-urlencoded
Content-length: 94

BV_Operation=BV_ExampleOp&BV_next_template=example.html.tmpl&base=1&count=1000&submit=Run+test

eof

--

   Patrick J. Horgan    patr...@broadvision.com   Have horse will ride.
   Opinions mine, not my employer's except by most bizarre coincidence.



 Fri, 09 Oct 1998 03:00:00 GMT   
 Generating an HTTP Request From a Script?

Thank You for the Response,

When trying to run the script, I got:

_________________________________________________________________
Can't locate LWP/UserAgent.pm in @INC at ./hello_remote.pl line 2.
BEGIN failed--compilation aborted at ./hello_remote.pl line 2.
_________________________________________________________________

I'm not real familiar with PERL 5...

The Lines I customized are underscored:

#!/usr/bin/perl -w
use LWP::UserAgent ;
$ua = new LWP::UserAgent ;
$ua->agent("Mozilla/3.0") ;  # Why didn't I hear about this?! ;-)
$req = new HTTP::Request 'POST', 'http://localhost/cgi-bin/form.cgi' ;
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

$req->content('name=me&email=...@here.com') ; #Filled in form data here
                       ^^^^^^^^^^^^^^^^^^^^

$req->header('Accept' => 'text/html') ;
$res = $ua->request($req) ;
if($res->is_success){
        print $res->content ;
        } else {
         print "Error: " . $res->code ." ". $res->message ;

Any ideas?

Thanks again,

Bill Koss
wk...@kingtech.com



 Fri, 09 Oct 1998 03:00:00 GMT   
 Generating an HTTP Request From a Script?
In article <317BD677.6...@kingtech.com>, Bill Koss  <wk...@kingtech.com> wrote:

You need to install libwww-perl.  It does not come standard with
perl5.  Visit http://www.sn.no/libwww-perl/

--
Gisle Aas                                         <a...@a.sn.no>
Schibsted Nett AS                                 http://www.sn.no/~aas/



 Fri, 09 Oct 1998 03:00:00 GMT   
 
   [ 7 post ] 

Similar Threads

1. shell script to log http request

2. Issuing http request via bash shell script

3. Make HTTP request from Unix shell script

4. Apache Proxy server that will transform an HTTP request in a HTTPS request

5. Can't process http/1.0 requests or proxy requests

6. Request - YACC generating C++ code

7. Generating random strings: Help requested.

8. Request for the format of an audit file generated by SunOS 4.1.4


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software