Gossamer Forum
Home : General : Perl Programming :

perl form post problems

Quote Reply
perl form post problems

I have just joined this forum because this is where the gurus are. I am not a regular perl programmer and actually work on the procurement product. I have to implement Single sign on into this application from procurement homepage. The procurement homepage is authenticated over siteminder. This product application is not on siteminder though and has its own webserver(IIS). To implement single sign on I have just one sample perl file which requires to be modified for my configuration. I do not have ready access to the web server to change permissions et al. I have access to the most files on it provided by the product company. I do not want to access any DB to authenticate because the link to logon into this product (from the homepage) is shown only to users active in the DB.

I managed to to do a redirect from the perl file to the Ariba server and login successfully. But what I want to do is the Post to avoid getting the parameters on the URL.

I have couple of problems: 1. I am not aware of how to debug the code? 2. I tried various combinations to post it but it each time resulted in either of:

(1) cgi error: headers not returned are: with nothing listedunder . (2) It does not post and a blank page is displayed or (3) HTTP 400 - Bad request.

So I do not know how to proceed or test the same. Can you please provide any light?

Here is the code which I am using:

use English;
use strict;
use CGI ();
use LWP::UserAgent ();
use HTTP::Request::Common qw(POST);

my $Webjump = "https://mydomain.com/IISProxy.asp?/webjump";

sub main ()
my $cgi = new CGI();
my $redirect = "$Webjump?";

my @parameterNames = $cgi->param();
foreach my $parameterName (@parameterNames) {
my $parameterValue = $cgi->param($parameterName);
if ($parameterName eq "SSOU"){
$SSOU = $parameterValue;
elsif ($parameterName eq "SSOS") {
$secretname = $parameterValue;
"Illegal parameter $parameterName passed to sso.pl");
$redirect .= "$parameterName=$parameterValue&";

print($cgi->redirect($redirect)); #=> This works!!


#my $userAgent = new LWP::UserAgent();

#my $req = new HTTP::Request POST => $Webjump;
#my $req = POST $Webjump,
# ['SSOU' => '$SSOU',
# 'SSOS' => '$secretname'];
#my $res = $userAgent->request($req);
#my $contentString = $res->as_string;

# my $form = [ "SSOU" => $SSOU,
# "SSOS" => $secretname];
#my $request = HTTP::Request::Common::POST($Webjump, $form);
#my $response = $userAgent->request($request);
#my $location = $BaseURL.$response->header('Location');
#$response->header('Location' => $location);
#my $contentString = $response->as_string;

# Kick off the script
Quote Reply
Re: [iganu] perl form post problems In reply to
I've not looked closely at your code but this is code I use to post so it works....you may be able to make use of it...

use LWP::UserAgent;
use HTTP::Request::Common qw/POST/;

my $ui = q|http://www.some-url.com/some-script.pl|;
my $ua = LWP::UserAgent->new( agent => 'Whatever/1.0', timeout => 30 );
my $re = $ua->request( POST $ui, [ param_one => 'value_one' ] );

if ($re->is_success) {
else {

Last edited by:

Paul: Apr 18, 2003, 4:20 PM
Quote Reply
Re: [Paul] perl form post problems In reply to
Yes. It works. I have another problem.

If that website is password protected, and I have the user id and the password, how to access the website by using perl?