Plese help me

H

HP

i am not ablt to convert this perl script into cgi

#!/3rdparty/contrib/bin/perl

use strict;
use warnings;
use HTTP::Request::Common;
use LWP::UserAgent;

my $svUser;
my $svPassword;

print "CNT Number: ";
chomp($svUser = <STDIN>);
print "Password: ";
system "stty -echo";
chomp($svPassword = <STDIN>);
system "stty echo";
print "\n";

my $svRequest = "Login";
my $url = "https://xx.xx.com";

my $ua = LWP::UserAgent->new;
my $res = $ua->request(POST $url, [svUser => $svUser, svPassword =>
$svPassword, svRequest => $svRequest]);
if ($res->is_success) {
my $resp = $res->as_string;
if($resp =~ /Invalid password/) {
print "Invalid Username/Password\n";
exit 1;
} else {
print "Login successful\n";
exit 0;
}
} else {
print "Failed: ", $res->status_line, "\n";
exit 1;
}


my cgi script is


#!/usr/bin/perl
use warnings;
use strict;
use HTTP::Request::Common;
use LWP::UserAgent;
use LWP::protocol::http;
use HTTP::Request;
use warnings;
#use LWP::Debug '+';
use Getopt::Long;
use Pod::Usage;
use XML::Simple;
use Data::Dumper;
use CGI;
my $cgi =new CGI;

my $svUser = $cgi->param("cnt");
my $svPassword = $cgi->param("passwd");
my $cr = $cgi->param("CR");



my $svRequest = "Login";
my $url = "https://xx.xx";
# exit with an error if the command-line parameters were not specified
#die "Usage: $0 <userid> <password> \n\n";
#unless defined $URL && length $URL

# Create user agent for querying data
my $ua = LWP::UserAgent->new();
# push @{ $ua->requests_redirectable }, 'POST';


# perform the request and obtain the response from the web server;

my $title = "";
my $mess = "";
my $res = $ua->request(POST $url, [svUser => $svUser, svPassword =>
$svPassword, svRequest => $svRequest]);
if ($res->is_success) {
my $resp = $res->as_string;
if($resp =~ /Invalid password/) {



$title = "authentication failed";
$mess = "Invalid Username/Password\n";



}
else {

$title = "authentication successful";
$mess = "Login successful";


}
}

print "Content-type: text/html\n\n";

print "<html><head>\n";
print "<title>$title</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\"
vlink=\"#800000\">\n";
print "<h1>$mess</h1>\n";


print "</body></html>\n";



i am not able to print the value of title and mess.
during the debugging i found out that the cgi script is not going into
authentication loop.
while my perl script is running fine on command line.
 
B

Brian McCauley

HP said:
Subject: Plese help me

Please put the subject of your post in the Subject of your post.

[ Snip - essentially the same question asked by the same person in
another thread a couple of hours earlier. ]

Please do not start new threads for no reason.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top