Plese help me

Discussion in 'Perl Misc' started by HP, Jan 5, 2006.

  1. HP

    HP Guest

    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.
     
    HP, Jan 5, 2006
    #1
    1. Advertising

  2. 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.
     
    Brian McCauley, Jan 5, 2006
    #2
    1. Advertising

  3. HP <> wrote:

    > Subject: Plese help me



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


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 5, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy, just Andy

    plese help a newbie with an online database

    Andy, just Andy, Jan 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    299
    John Timney \(Microsoft MVP\)
    Jan 27, 2004
  2. =?Utf-8?B?dHJlbGxvdzQyMg==?=

    HELP! HELP! HELP! Opening Web Application Project Error

    =?Utf-8?B?dHJlbGxvdzQyMg==?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    792
    =?Utf-8?B?dHJlbGxvdzQyMg==?=
    Feb 20, 2004
  3. Harvey
    Replies:
    0
    Views:
    750
    Harvey
    Jul 16, 2004
  4. Harvey
    Replies:
    1
    Views:
    880
    Daniel
    Jul 16, 2004
  5. Xin Xiao

    plese problem std_logic_vector

    Xin Xiao, Dec 2, 2007, in forum: VHDL
    Replies:
    5
    Views:
    503
Loading...

Share This Page