Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Not able to convert into cgi script

Reply
Thread Tools

Not able to convert into cgi script

 
 
HP
Guest
Posts: n/a
 
      01-05-2006
Hi All

i have written prtl script
but when i am converting into the cgi scipt its not printing the value

perl script is-


#!/3rdparty/contrib/bin/perl

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

my $svUser;
my $svPassword;

print " 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:1343/fwua.htm";

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://47.152.183.41:3443/fwua.htm";
# 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";



exit 1;
}
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 "<a href=\"../perl/tutorial.html\"><b>Back</b></a> to the
Tutorial\n";
print "</body></html>\n";


when i debug the code i found that my program is not going into the
authentication loop.so it s not printing the value of $title and $mess.

please help me out.

 
Reply With Quote
 
 
 
 
HP
Guest
Posts: n/a
 
      01-05-2006
comman please some one help me out

 
Reply With Quote
 
 
 
 
HP
Guest
Posts: n/a
 
      01-05-2006
common please some one help me out

 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-05-2006
[ No answer after 2 hours? How rude of us! ]

HP wrote:
>
> #!/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;


Are you using all those modules?

This is one module you ought to use when debugging a CGI script:

use CGI::Carp 'fatalsToBrowser';

> if ($res->is_success) {
> my $resp = $res->as_string;
> if($resp =~ /Invalid password/) {
>
> $title = "authentication failed";
> $mess = "Invalid Username/Password\n";
>
> exit 1;


Do you really want the script to exit there?

Btw, your indenting style is a little odd...

> when i debug the code i found that my program is not going into the
> authentication loop.


I don't see any loop.

> so it s not printing the value of $title and $mess.


What does it do then? Which error messages does it generate?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
HP
Guest
Posts: n/a
 
      01-05-2006
Hi Gunnar

hey i mean its falling into
if ($res->is_success)

so its not printing the value of $title and $mess.

 
Reply With Quote
 
HP
Guest
Posts: n/a
 
      01-05-2006
i am getting this error on browser

Failed: 500 Can't load
'/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/HTML/Parser/Parser.so'
for module HTML:arser:
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/HTML/Parser/Parser.so:
failed to map segment from shared object: Permission denied
Content-type: text/htm

 
Reply With Quote
 
Samwyse
Guest
Posts: n/a
 
      01-05-2006
HP wrote:
> i am getting this error on browser
>
> Failed: 500 Can't load
> '/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/HTML/Parser/Parser.so'
> for module HTML:arser:
> /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/HTML/Parser/Parser.so:
> failed to map segment from shared object: Permission denied
> Content-type: text/htm


Your web server is running as some user. The file Parser.so apparently
has its permissions set such that this user can't read the file.
 
Reply With Quote
 
Dr.Ruud
Guest
Posts: n/a
 
      01-05-2006
HP schreef:

> so its not printing


For HP and everybody else with "User-Agent: G2/#.#":

"How can I automatically quote the previous message when I post a
reply?"
http://groups.google.co.uk/support/b...y?answer=14213

See also:
http://www.safalra.com/special/googlegroupsreply/

What's good 'netiquette' when posting to Usenet?
http://groups.google.co.uk/support/b...y?answer=12348
http://directory.google.com/Top/Comp...net/Etiquette/

But Google needs you to vote for 'Default quoting of previous message in
replies'
http://groups-beta.google.com/suppor..._type=features

--
Affijn, Ruud

"Gewoon is een tijger."

 
Reply With Quote
 
HP
Guest
Posts: n/a
 
      01-05-2006
Hi
So what should i do , make it right.
i mean please suggest me some solution.

 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-05-2006
[ You replied to a message in the Usenet group comp.lang.perl.misc. Even
if you posted from an interface provided by Google, most readers use
other tools for reading Usenet groups. Hence it's very important to
provide some context when you reply to a message, or else people who
might be able to help won't have a clue what you are talking about.
Typically that's accomplished by quoting parts of the message you are
replying to. ]

HP wrote:
> i am getting this error on browser
>
> Failed: 500 Can't load
> '/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/HTML/Parser/Parser.so'
> for module HTML:arser:
> /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/HTML/Parser/Parser.so:
> failed to map segment from shared object: Permission denied
> Content-type: text/htm


Samwyse gave you a plausible explanation.

In addition to that, I'm not sure why your script is trying to load
HTML:arser, so one way to get rid of the error might be to not load a
bunch of modules that you still don't make use of.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
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
C++ calling perl script - Not able to get the stack arguments pushedrom XPUSH in perl script Yogi Perl Misc 1 09-13-2012 11:30 AM
Not able to display color in excel not able to display color in excel using xml sed_y XML 0 02-15-2012 09:46 PM
How to convert exe file of cgi script into .cgi extension. Muzammil C++ 1 08-28-2008 07:50 PM
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
Python-cgi or Perl-cgi script doubt praba kar Python 1 07-30-2005 08:25 AM



Advertisments