Solved

Submit HTML form via Perl

Posted on 2011-02-24
3
661 Views
Last Modified: 2013-12-25
Can anyone provide a short example (or link to one) demonstrating how (if possible) to submit form data to a Perl script at a url using Perl?

The purpose is to automate testing. The remote script requires basic authentication. Other then that the form data is basic.

Thanks in Advance.


0
Comment
Question by:kindaprog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
group0 earned 500 total points
ID: 34982465
Those links don't help because they don't describe doing form submission in combination with basic auth.  Here's an example:

use LWP::UserAgent;
use strict;

my $server = 'www.domain.com:80';
my $realm = 'example realm';
my $username= 'user';
my $password = 'pass';

my $ua = LWP::UserAgent->new;
$ua->credentials($server, $realm, $username => $password);
my $response = $ua->post('http://www.domain.com/form.cgi',
	{
		'param1' => 'value1',
		'param2' => 'value2',
		'submit' => 'submit',
	}
);
if ($response->is_success) {
	print $response->content . "\n";
} else {
	die($response->status_line);
}

Open in new window


Just modify the variables to match your form and auth setup, but be sure not to drop the port or add http:// in the $server variable, or auth will fail.
0
 

Author Closing Comment

by:kindaprog
ID: 35041727
Excellent. Thank you. Sorry I took so long getting back to you.
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question