Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Plese help me

Reply
Thread Tools

Plese help me

 
 
HP
Guest
Posts: n/a
 
      01-05-2006
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:rotocol::http;
use HTTP::Request;
use warnings;
#use LWP:ebug '+';
use Getopt::Long;
use Pod::Usage;
use XML::Simple;
use Data:umper;
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.

 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      01-05-2006
HP wrote:

> 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.

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      01-05-2006
HP <(E-Mail Removed)> wrote:

> Subject: Plese help me



Plese put the subject of your article in the Subject of your article.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plese Can Somebody Solve This Boolean Question adilef2213 General Computer Support 0 11-01-2009 06:04 PM
plese problem std_logic_vector Xin Xiao VHDL 5 12-03-2007 03:37 PM
Plese Help.... sam MCAD 1 05-25-2004 02:54 AM
Plese Help - NSW 2003 Pro Uninstall Has Replaced Folders With Gobbledy-Gook File Names :( GoLeafsGo Computer Support 12 01-28-2004 02:57 AM
plese help a newbie with an online database Andy, just Andy ASP .Net 1 01-27-2004 11:01 PM



Advertisments