Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy perl works on command line but not in apache2 cgi-bin

    I created a very simple program:

    Code:
    #!C:/Perl/bin/perl.exe
    use LWP::UserAgent;
    my $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
    my $ua = LWP::UserAgent->new;
    my $res = $ua->get( $url );
    my $req = HTTP::Request->new(GET => $url);
    my $res = $ua->request($req);
    print "Content-type: text/html\r\n\r\n";
    print $res->content;
    exit (0);
    It works from the command line. It does not work when called from a browser.

    OS:Windows XP,
    Located in C:\Program Files\Apache Software Foundation\Apache2.2\cgi-bin.
    cgi-bin was verified working with simple HelloWorld.pl program.

    Browser Output:
    500 Can't locate object method "new" via package "Net::SSL"

    It is as if when executed in cgi-bin, it forgets where all the perl modules are.

    Please Help. Thanks.

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,872
    Thanks
    2
    Thanked 164 Times in 159 Posts
    You need to install the Net::SSL module and it might be best to also install Crypt::SSLeay and/or IO::Socket::SSL

    http://cpansearch.perl.org/src/GAAS/...826/README.SSL

  • #3
    Senior Coder
    Join Date
    Mar 2006
    Posts
    1,274
    Thanks
    2
    Thanked 39 Times in 38 Posts
    If it works from the command line he must already have the modules installed, no?

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,872
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Quote Originally Posted by KevinADC View Post
    If it works from the command line he must already have the modules installed, no?
    lol, You're right, I guess it was still a little early for me to think clearly.

    This is just a guess, but do you have 2 versions of Perl installed on this box? If so, apache could be seeing a different version than what is seen when executing on the command line and this other version doesn't have the required modules in its @INC path.

  • #5
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But it works from the command line when outside of cgi-bin. It only fails when called through cgi-bin. Please explain why adding NET::SSL is relevant. Why would this behave differently through cgi-bin and when executed directly? Thanks. Adding NET::SSL and IO::Socket::SSL did not help. I'm suspecting an environmental problem.

  • #6
    Senior Coder
    Join Date
    Mar 2006
    Posts
    1,274
    Thanks
    2
    Thanked 39 Times in 38 Posts
    I don't know why it is not working when run as a cgi especially since you are running it from localhost using Windows XP. As far as I know, it should work.

  • #7
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FishMonger View Post
    lol, You're right, I guess it was still a little early for me to think clearly.

    This is just a guess, but do you have 2 versions of Perl installed on this box? If so, apache could be seeing a different version than what is seen when executing on the command line and this other version doesn't have the required modules in its @INC path.
    This is a possibility...Can you elaborate on what I should be looking for?(@INC) Thanks

  • #8
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Env is definitely messed up. Switched over to IIS instead of apache and it works fine. Will reinstall apache/perl later and try again. Thanks for all the input


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •