2

I wrote some code with help from examples but when I run it I'm getting error in Ubuntu Server 12.04.2 LTS:

Failed to connect to , problem connecting to "localhost", port 4242: Connection refused at /usr/local/share/perl/5.14.2/MozRepl/Client.pm line 144

How can i fix this ?

#!/usr/bin/perl -w
use strict;
use WWW::Mechanize::Firefox;
use HTTP::Cookies;

my $username = "test";
my $password = "t3st";

my $mech = WWW::Mechanize::Firefox->new();
$mech->get("http://test.com/login.php"); print "Logging, Please Wait.\n";
$mech->submit_form(
    form_number => 0,
    fields => {
        username => "$username",
        password => "$password",
    }
);
RobEarl
  • 7,862
  • 6
  • 35
  • 50
Essential
  • 21
  • 1
  • 2
  • Have you tried `localhost 0 4242`? – Ragen Dazs May 24 '13 at 16:48
  • 1
    this isn't a Perl question. Your problem is either: 1., that no service (such as mozrepl) is listening on localhost port 4242, or 2., that your firewall is blocking or manipulating localhost traffic on port 4242 in such a way that connections to it immediately fail. – Julian Fondren May 25 '13 at 02:33

3 Answers3

3
  • Install MozRepl firefox add-on on your firefox
  • Once installed, start the MozRepl in your firefox as below:

    Tools->MozRepl->Start

  • Confirm that MozRepl is listening on port 4242 as below:

    netstat -anp | grep firefox

    tcp 0 0 127.0.0.1:4242 0.0.0.0:* LISTEN 1438/firefox

Good Luck !!

Note: I am not able to format this answer properly as SO formatting is not working as expected.

slayedbylucifer
  • 22,878
  • 16
  • 94
  • 123
1

It is important to add to the answers above that since version 18, Firefox no longer displays the "Tools" menu unless you type the F10 key, or select "Options -> Menu bar".

Phil Goetz
  • 549
  • 4
  • 14
0

Do you have the mozrepl plugin installed and enabled and configured for port 4242?

ysth
  • 96,171
  • 6
  • 121
  • 214