Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Mechanize:submit_form issue.

by perlcoding (Initiate)
on Sep 15, 2009 at 15:52 UTC ( [id://795414]=perlquestion: print w/replies, xml ) Need Help??

perlcoding has asked for the wisdom of the Perl Monks concerning the following question:

Hello People,
I'm running into some issue where in i can't figure out why.Here's whats happening,

The are two links where i'm trying to login,using www::mechanize,
1) http://host:7777/fagcs_302_C600_sfosun05/domain/
2) http://host:7778/fagcs_320_C106_sfoaix04/domain/
The submit_form works perfectly fine for second link but not the first one.
I'm getting this error/status "Couldn't submit form:500::500 Server closed connection without sending any data back".
Please guide me as to why it would no work for first case,how do i diagonize the issue?
Please not that,i can manually login to both pages with same usrname and pswd.
Please find the code below:

use strict; use WWW::Mechanize; my $url = 'http://host:7777/fagcs_302_C600_sfosun05/domain/'; #my $url = 'http://host:7778/fagcs_320_C106_sfoaix04/domain/'; my $username = 'usrname'; my $password = 'pswd'; my $agent = WWW::Mechanize->new(); $agent->get ($url); #print $agent->content(); if($agent->success()){ eval { $agent->submit_form ( form_number => 0, fields => { 'j_username' => $username, 'j_password' => $password, }, ); }; if ($@) {print "error :($@) "; } print "Couldn't submit form:".$agent->status() .":".":".$agent->conten +t()."\n" unless $agent->success; }

Replies are listed 'Best First'.
Re: Mechanize:submit_form issue.
by Herkum (Parson) on Sep 15, 2009 at 17:58 UTC

    500 implies that there is a server error of some sort. I would check the error.log of the second server. To verify the 500 Server error I would manually attempt to access the web page with the values you are trying to pass. You might be sending what you think you are.

Re: Mechanize:submit_form issue.
by Anonymous Monk on Sep 16, 2009 at 10:54 UTC
    Since you seem to be using autocheck, you should write your program like this The error "500 Server closed connection without sending any data back" indicates a problem with the server. You should try to see if it works from a browser like Firefox (Firebug), and if it does, you should install livehttpheaders, and compare what firefox sends to what your program(mechanize) sends.
      Hello folks, thanks for the replies.
      I wasn't able to test the suggestion you provided.
      I shall hope to try out your suggestions by EOD tommorow.

      My special thanks to the anonymous monk,that is something new to me.

      Will update you folks on the same.

        Hey folks please help me.
        Its a critical task for me now.
        Now the script is throwing this error message
        "Error POSTing http://host:12501/adhoc_sfosun05/login/login.do"
        What should we understand when we get "Error POSTing". I can't seem to get around with this task.
        Seems like when script executes submit_form statement than it throws the above message.
        Please help me.

Re: Mechanize:submit_form issue.
by Sewi (Friar) on Sep 15, 2009 at 19:57 UTC
    If both ports are on the same server, I'ld guess one of them may be a https - port.
    Try telnet host 7777 and once connected, type GET / HTTP/1.0 and press ENTER/RETURN twice. Read the reply and try again using the other port.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://795414]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-16 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found