Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to submit form from perl?

Status
Not open for further replies.

Travistee2

Technical User
Aug 11, 2005
15
US
I want to write a perl script to fill out a form and submitit.

This is the url the form sends data to.

print
"Location:e=cindy&subject=new&body=saysomething";

Should this work?
If it does, how do I get it to continue in the script instead
of ending the script on the "print location"?
 
first, that is not a form, that is a URI that is sending data to a script in the query string. Similar to a form, but not a form.

Without having any idea what you are trying to do, I suggst you look into the LWP module since it sounds like you want to send and recieve data and process the data the remote script returns to your script.
 
print
"Location:e=cindy&subject=new&body=saysomething";

I am trying to simulate what the form sends to the script.

<a name="post"><center><h2>Post A Message!</h2></center></a>
<form method=POST action="/cgi-bin/
So, the form uses the POST method to send the string to the
perl script.

I want to send the same post to multiple scripts
 
This wouldn't be for a board spamming application would it?
 
I already told you what to look into, LWP, hopefully I am not unwittingly assisting a person looking to send spam.
 
Don't get paranoid. Its not for spamming forums. I have a few forums of my own that I want to post the same things to.
 
I looked at the LWP module. It has quite a long list of functions.

Can someone narrow it down to the ones that let me send data to another script as if it was sent from a FORM POST.

Since I have no control over the script it is sending to, I
can't assume I will have something to check to see if it was succesful.

Do I really have to use the LWP module, or is there a more direct way to code it.

Thanks
 
LWP is simple, look at the examples

on your command line
Code:
perldoc lwpcook

HTH
--Paul

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I tried this based on the example I found at:

############
use strict;
use warnings;
#use LWP 5.64;
use LWP::Simple;
my $browser = LWP::UserAgent->new;

my $url = ' my $response = $browser->post( $url,
[ 'name' => 'cindy', 'email' => 'cindy@nowhere.com',
'subject' => 'new', 'body' => 'whatever I wrote',
]
);
print "form was sent";

############

I had to take out
#use LWP 5.64;
because it gets an internal server error.
So I replaced it with use LWP::Simple;

However when I tried it with
use LWP::Simple;
I don't get an error,but I just get a blank page, not
even printing "form was sent";

Any ideas on what I am missing?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top