#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    327
    Rep Power
    0

    MozRepl installation errors on opensuse 12.2 - with mozilla firefox version 16.01


    gentlemen,

    I want to install mozrepl on OpenSUSE version 12.2. It gets pretty tricky - note Mozrepl is a additional part that is needed by the WWW::Mechanize::Firefox::
    I had a bunch of troubles with mozRepl - and I tried to follow the first 3-4 steps from CPAN. I tried to install it with zypper in or with the repo: https://github.com/bard/mozrepl.github

    See many good links and ressources regarding Mechanize - Firefox - Troubleshooting https://duckduckgo.com/html/?q=mozrepl https://github.com/bard/mozrepl.github

    see the issues that were reported:

    https://addons.mozilla.org/en-US/firefox/addon/mozrepl/


    note: does the firefox version 16.01 on opensuse 12.2 cause any issues

    note: mozrepl is listening on port 4242

    note: see the testscript:

    PHP Code:
      use WWW::Mechanize::Firefox;
      
    my $mech WWW::Mechanize::Firefox->new(
          
    tab => 'current',
      );
      
    $mech->get('http://google.com',
          
    ':content_file' => 'google_com.html' ); 
    and the issues

    PHP Code:

    martin
    @linux-wyee:~/perlperl moz_test3.pl
    Can
    't locate WWW/Mechanize/Firefox.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.16.0 /usr/lib/perl5/vendor_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.16.0 /usr/lib/perl5/5.16.0/i586-linux-thread-multi /usr/lib/perl5/5.16.0 /usr/lib/perl5/site_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.16.0 /usr/lib/perl5/site_perl .) at moz_test3.pl line 1.
    BEGIN failed--compilation aborted at moz_test3.pl line 1.
    martin@linux-wyee:~/perl> 
    what can i do now!?

    look forward to hear from you

    greetings
    Last edited by metabo; October 30th, 2012 at 03:20 PM. Reason: more infos
  2. #2
  3. 'fie' on me, allege-dly
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    Location
    in da kitchen ...
    Posts
    12,894
    Rep Power
    6444
    Run that script under your own user and check the paths are the same ...
    --Ax
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
    BIT COINS ANYONE
  4. #3
  5. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    Can't locate WWW/Mechanize/Firefox.pm in @INC
    That's a very specific error message.

    When you install that module from CPAN, take note of where it installs. There will be a message telling you if the install was successful, and which directory the module was moved to. If multiple versions of perl are causing the problem, that will be an important clue.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    327
    Rep Power
    0
    Originally Posted by keath
    That's a very specific error message.

    When you install that module from CPAN, take note of where it installs. There will be a message telling you if the install was successful, and which directory the module was moved to. If multiple versions of perl are causing the problem, that will be an important clue.


    hello again dear keath

    hmmm probably i have two instances of perl.


    i have various issues with installing and running WWW::Mechanize::FireFox on my machine.

    -well: Mechanize FireFox lets you use FireFox with the Same behaviour as Perl Mechanize itself. You can do many
    good things -and this lets so save time. A great perl-option to overcome obstacles i enveryday live.



    i have had a closer look at the many things


    Q:
    do i have two instances of Perl on the machine?!
    did i manage to install Mecha::FireFox correctly
    is FireFox running with JavaScript enabled.


    One of the key items on my CPAN configuration is 'prerequisite_policy [follow]';
    Well to be frank that is the most sensible choice.
    If a prerequisite module is missing, it will be installed automatically. Well i have looked at many things - my trace shows this happening; some of the modules needed are probably missing,

    so it tries to install them before installing WWW::Mechanize::Firefox.
    I do note that my config contains several strange things ...




    PHP Code:


    use WWW::Mechanize::Firefox;
      
    my $mech WWW::Mechanize::Firefox->new(
          
    tab => 'current',
      );
      
    $mech->get('http://google.com',
          
    ':content_file' => 'google_com.html' ); 



    see this

    PHP Code:

     martin
    @linux-wyee:~/perlperl moz_test3.pl
    Can
    't locate WWW/Mechanize/Firefox.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.16.0 /usr/lib/perl5/vendor_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.16.0 /usr/lib/perl5/5.16.0/i586-linux-thread-multi /usr/lib/perl5/5.16.0 /usr/lib/perl5/site_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.16.0 /usr/lib/perl5/site_perl .) at moz_test3.pl line 1.
    BEGIN failed--compilation aborted at moz_test3.pl line 1.
    martin@linux-wyee:~/perl> 
    and have a look here

    PHP Code:

    cpan
    [1]>  o conf
    $CPAN
    ::Config options from /root/.cpan/CPAN/MyConfig.pm:
        
    commit             [Commit changes to disk]
        
    defaults           [Reload defaults from disk]
        
    help               [Short help about 'o conf' usage]
        
    init               [Interactive setting of all options]

        
    applypatch         []
        
    auto_commit        [0]
        
    build_cache        [100]
        
    build_dir          [/root/.cpan/build]
        
    build_dir_reuse    [0]
        
    build_requires_install_policy [yes]
        
    bzip2              [/usr/bin/bzip2]
        
    cache_metadata     [1]
        
    check_sigs         [0]
        
    colorize_debug     undef
        colorize_output    
    [0]
        
    colorize_print     undef
        colorize_warn      undef
        commandnumber_in_prompt 
    [1]
        
    commands_quote     undef
        connect_to_internet_ok 
    [1]
        
    cpan_home          [/root/.cpan]
        
    curl               undef
        dontload_hash      undef
        dontload_list      undef
        ftp                undef
        ftp_passive        
    [1]
        
    ftp_proxy          []
        
    ftpstats_period    undef
        ftpstats_size      undef
        getcwd             
    [cwd]
        
    gpg                [/usr/bin/gpg]
        
    gzip               [/usr/bin/gzip]
        
    halt_on_failure    [0]
        
    histfile           [/root/.cpan/histfile]
        
    histsize           [100]
        
    http_proxy         []
        
    inactivity_timeout [0]
        
    index_expire       [1]
        
    inhibit_startup_message [0]
        
    keep_source_where  [/root/.cpan/sources]
        
    load_module_verbosity [none]
        
    lynx               undef
        make               
    [/usr/bin/make]
        
    make_arg           []
        
    make_install_arg   []
        
    make_install_make_command [/usr/bin/make]
        
    makepl_arg         []
        
    mbuild_arg         []
        
    mbuild_install_arg []
        
    mbuild_install_build_command [./Build]
        
    mbuildpl_arg       []
        
    ncftp              undef
        ncftpget           undef
        no_proxy           
    []
        
    pager              [less]
        
    password           undef
        patch              
    []
        
    patches_dir        undef
        perl5lib_verbosity 
    [none]
        
    prefer_external_tar [1]
        
    prefer_installer   [MB]
        
    prefs_dir          [/root/.cpan/prefs]
        
    prerequisites_policy [follow]
        
    proxy_pass         undef
        proxy_user         undef
        randomize_urllist  undef
        scan_cache         
    [atstart]
        
    shell              [/bin/bash]
        
    show_unparsable_versions [0]
        
    show_upload_date   [0]
        
    show_zero_versions [0]
        
    tar                [/bin/tar]
        
    tar_verbosity      [none]
        
    term_is_latin      [1]
        
    term_ornaments     [1]
        
    test_report        [0]
        
    trust_test_report_history [0]
        
    unzip              [/usr/bin/unzip]
        
    urllist           
            0 
    [http://artfiles.org/cpan.org/]
            
    [http://www.idg.pl/mirrors/CPAN/]
            
    [http://ftp.heanet.ie/mirrors/ftp.perl.org/pub/CPAN/]
        
    use_sqlite         [0]
        
    username           undef
        version_timeout    
    [15]
        
    wait_list          undef
        wget               
    [/usr/bin/wget]
        
    yaml_load_code     [0]
        
    yaml_module        [YAML
    what do you say. I guess that this strange behaviour i get everytime i try to start Mechnize-FireFox is quite a side-effect of my installation and configuration

    look forward to hear from you
  8. #5
  9. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    Having prerequisite_policy set to follow is a sensible choice, but it's not really relevant to your problem.

    The question I asked was, where did cpan install the module? Try it again, and take note of the directory it's loading into. Maybe it never was installed at all. Perhaps the installation failed.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    327
    Rep Power
    0
    hello Keath



    thx for your answer - and the subsequent question. I will do some other trials - and will let you know the results.

    stay tuned - i coome back to you later the week

    grreetings
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    327
    Rep Power
    0
    hello dear Keath - many thanks for all the help.

    well i have bad luck here.


    i tried to install on OpenSuse 12.2 -
    as a superuser SU or
    as Martin - which is a normal ordinary user...

    well all faield untill now.


    see the concrete results that i got back... see the source below....

    and here...

    www.schulcenter.org/image_uploads/my_mechanize_install.pdf





    PHP Code:
    cpan[4]>  install WWW::Mechanize::Firefox


    und in TAP output
    Files
    =83Tests=78,  6 wallclock secs 0.31 usr  0.09 sys +  4.63 cusr  0.59 csys =  5.62 CPU)
    ResultFAIL
    Failed 78
    /83 test programs14/78 subtests failed.
    make: *** [test_dynamicFehler 2
      CORION
    /WWW-Mechanize-Firefox-0.68.tar.gz
    one dependency not OK 
    (MozRepl::RemoteObject); additionally test harness failed
      
    /usr/bin/make test -- NOT OK
    //hint// to see the cpan-testers results for installing this module, try:
      
    reports CORION/WWW-Mechanize-Firefox-0.68.tar.gz
    Running make install
      make test had returned bad status
    won't install without force
    Failed during this command:
     ZIGOROU/MozRepl-0.06.tar.gz                  : make_test NO
     CORION/MozRepl-RemoteObject-0.34.tar.gz      : make_test NO one dependency not OK (MozRepl)
     CORION/WWW-Mechanize-Firefox-0.68.tar.gz     : make_test NO one dependency not OK (MozRepl::RemoteObject); additionally test harness failed

    cpan[4]>  install WWW::Mechanize::Firefox 


    see much much more here -

    www.schulcenter.org/image_uploads/my_mechanize_install.pdf


    love to hear from you

    greetings
  14. #8
  15. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    There's little I can do. I am not running the same OS as you, so it's going to mean very little if I can get the module to build.

    I can only point out that the one error is repeated over and over: "Can't locate MozRepl/RemoteObject.pm in @INC"

    You've said in other posts that you have the pre-requisites policy for CPAN set to 'follow', which should have caused the build process to install that module first. For some reason it failed to, so you should attempt to build that module directly, by installing it specifically from CPAN.

    install MozRepl::RemoteObject
    If it fails to install, which it might, note the specific errors related to that module.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    327
    Rep Power
    0
    hello dear Keath

    many many thanks - i appreciate every posting from you. and i will do as adviced.

    i will do all you advice.

    as for now: here some more insights: see the folliwing


    i ve set up another notebook with opensuse - and as i have had various errors with the make - i installed gcc this time. And with this i got more propper results:


    PHP Code:
    cpan[4]>   install WWW::Mechanize::Firefox 
    WWW
    ::Mechanize::Firefox is up to date (0.68). 

    After the installation i used several scripts from the Mechanize-Examples (see here
    http://search.cpan.org/~corion/WWW-Mechanize-Firefox-0.68/lib/WWW/Mechanize/Firefox/Examples.pm )

    And i would say that those results were really a bit better than all i got untill now. See the terminal-results - and the corresponding code below...

    example3

    Code:
    martin@linux-ale9:~/perl> perl exa3.pl
    Bareword found where operator expected at exa3.pl line 61, near "--current"
            (Missing operator before current?)
    Bareword found where operator expected at exa3.pl line 63, near "--mozrepl"
            (Missing operator before mozrepl?)
    Bareword found where operator expected at exa3.pl line 65, near "--type"
            (Missing operator before type?)
    Number found where operator expected at exa3.pl line 69, near "over 4"
            (Do you need to predeclare over?)
    Bareword found where operator expected at exa3.pl line 106, near "The"
            (Missing semicolon on previous line?)
    Bareword found where operator expected at exa3.pl line 107, near "at"
            (Missing semicolon on previous line?)
    syntax error at exa3.pl line 51, near "="
    "use" not allowed in expression at exa3.pl line 73, at end of line
    "use" not allowed in expression at exa3.pl line 95, at end of line
    Execution of exa3.pl aborted due to compilation errors.
    martin@linux-ale9:~/perl>



    example5
    Code:
    martin@linux-ale9:~/perl> perl exa5.pl
    Can't find string terminator "JS" anywhere before EOF at exa5.pl line 4.
    martin@linux-ale9:~/perl> perl exa6.pl
    Failed to connect to , Couldn't load "MozRepl::Plugin::Base", "Attempt to reload MozRepl/Plugin/Base.pm aborted.
    Compilation failed in require at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 82.
    " at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 84.

    example6

    Code:
    martin@linux-ale9:~/perl> perl exa6.pl
    Failed to connect to , Couldn't load "MozRepl::Plugin::Base", "Attempt to reload MozRepl/Plugin/Base.pm aborted.
    Compilation failed in require at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 82.
    " at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 84.

    see the corresponding code - that i have taken from the above mentioned site.

    example-code 3
    Code:
        GetOptions(
            'mozrepl|m:s' => \my $mozrepl,
            'tab:s' => \my $tab,
            'current|c' => \my $use_current_tab,
            'close|q' => \my $close,
            'title|t:s' => \my $title,
            'type:s' => \my $encode_type,
            #'focus|f' => \my $focus,
        ) or pod2usage();
        
        $tab = $use_current_tab ? 'current'
               : $tab ? qr/$tab/
               : undef
               ;
        
        $title ||= getcwd;
        
        my $mech = WWW::Mechanize::Firefox->new(
            tab     => $tab,
            repl    => $mozrepl,
            create  => 1,
            autoclose => $close,
        );
        
        local $/;
        binmode STDIN;
        my $html = <>;
        
        # Find out whether we have HTML:
        if (! $encode_type) {
            if ($html =~ /^\s*</sm) {
                $encode_type = 'html'
            } else {
                $encode_type = 'text',
            };
        };
        
        if ('text' eq $encode_type) {
            my %map = (
            '<' => '&lt;',
            '>' => '&gt;',
            '&' => '&amp;',
            );
            $html =~ s/([<>&])/$map{$1} || $1/ge;
            $html =~ s/\r?\n/<br>/g;
            $html = "<html><head><title>$title</title><body><pre>$html</pre></body></html>";
        };
        
        $mech->update_html($html);
        
        =head1 NAME
        
        bcat.pl - cat HTML to browser
        
        =head1 SYNOPSIS
        
          bcat.pl <index.html
        
        Options:
           --tab            title of tab to reuse (regex)
           --current        reuse current tab
           --title          title of the page
           --mozrepl        connection string to Firefox
           --close          automatically close the tab at the end of input
           --type TYPE      Fix the type to 'html' or 'text'
        
        =head1 OPTIONS
        
        =over 4
        
        =item B<--tab>
        
        Name of the tab to (re)use. A substring is enough.
        
        =item B<--current>
        
        Use the currently focused tab.
        
        =item B<--title>
        
        Give the title of the page that is shown.
        
        =item B<--close>
        
        Automatically close the tab when the input closes. This is good
        for displaying intermediate information.
        
        =item B<--type TYPE>
        
        Force the type to be either C<html> or C<text>. If the type is
        C<text>, line wrapping will be added.
        
        =item B<--mozrepl>
        
        Connection information for the mozrepl instance to use.
        
        =back
        
        =head1 DESCRIPTION
        
        B<This program> will display HTML read from STDIN
        in a browser tab.
        
        =head1 SEE ALSO
        
        The original C<bcat> utility which inspired this program
        at L<http://rtomayko.github.com/bcat/>.
        
        =cut


    example-code 5 perlscript 5


    Code:
            my $ff = Firefox::Application->new();
        
        # Check the network proxy settings
        my $prefs = $ff->repl->expr(<<'JS');
          Components.classes["@mozilla.org/preferences-service;1"]
            .getService(Components.interfaces.nsIPrefBranch);
        JS
        
        print "Your proxy settings are\n";
        print "Proxy type\t",  $prefs->getIntPref('network.proxy.type'),"\n";
        print "HTTP  proxy\t", $prefs->getCharPref('network.proxy.http'),"\n";
        print "HTTP  port\t",  $prefs->getIntPref('network.proxy.http_port'),"\n";
        print "SOCKS proxy\t", $prefs->getCharPref('network.proxy.socks'),"\n";
        print "SOCKS port\t",  $prefs->getIntPref('network.proxy.socks_port'),"\n";
        
        # Switch off the proxy
        if ($prefs->getIntPref('network.proxy.type') != 0) {
            $prefs->setIntPref('network.proxy.type',0);
        };
        
        # Switch on the manual proxy configuration
        $prefs->setIntPref('network.proxy.type',1);
        
        
        =head1 NAME
        
        proxy-settings.pl - display and change the proxy settings of Firefox
        
        =head1 SYNOPSIS
        
        proxy-settings.pl
        
        =head1 DESCRIPTION
        
        This shows how to read and write configuration settings
        from L<about:config> . Particularly, it shows how
        to switch the proxy settings in Firefox on and off.
        
        =cut

    example perlscript 6 - this is a script of my own...
    Code:
        
        #!/usr/bin/perl 
     
    use WWW::Mechanize::Firefox; 
    use strict; 
    use warnings; 
    #use Parallel::ForkManager; 
     
     
     
    #my $fork = Parallel::ForkManager->new(2); 
     
    #sites 
    my @urls = qw(http://www.google.com http://www.yahoo.com http://www.cnn.com http://www.bing.com http://www.nbcnews.com/); 
    #temp base dir 
    my $temp = '/home/aaron/cgi-bin/'; 
     
    for my $each (@urls){ 
    	#$fork->start and next; 
    	my $mech = WWW::Mechanize::Firefox->new(launch => 'firefox',create => 1,); 
    	 
    	$each =~ /www\.(\w+)\.com/; 
    	my $name = $1; 
    	print "creating $name.png\n"; 
    	 
    	 
    	$mech->get($each); 
    	my $png = $mech->content_as_png(undef, undef, {width => 240,height => 240}); 
    	 
    	my $dir_name = "$temp/$name".".png"; 
    	open my $file, ">", "$dir_name" or die "couldnt create $temp/$1.png"; 
    	binmode $file; 
    	print {$file} $png; 
    	 
    	close $file; 
    	sleep 5; # sleep some to give it a little time to make sure things compleated..... you'll need this more using fork 
    	 
    	#$fork->finish; 
    } 
    print "Well All done!\n"; 
    #$fork->wait_all_children;

    Well - i think that these errors that i have shown above are somewhat different to the others that we discussed in the initlal posting.

    What do you say!? I am interested to hear from you

    greetings.
    Last edited by metabo; November 11th, 2012 at 01:54 PM.
  18. #10
  19. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    It seems likely that many of your errors are cut and paste errors. For example, in the example3 script, you have bareword error messages for things like --current.

    The reason appears to be because you have space in front of the perldoc directives such as =head1

    Code:
        =head1 NAME
        
        bcat.pl - cat HTML to browser
        
        =head1 SYNOPSIS
        
          bcat.pl <index.html
        
        Options:
           --tab            title of tab to reuse (regex)
           --current        reuse current tab
           --title          title of the page
           --mozrepl        connection string to Firefox
           --close          automatically close the tab at the end of input
           --type TYPE      Fix the type to 'html' or 'text'
        
        =head1 OPTIONS
    The equal sign has to be the first thing on the line. No space in front. If you use a good text editor that color codes perl syntax, you would see the error. All of that text is basically just comments, but because of the extra spaces, the perl interpreter doesn't realize it is documentation and is trying to execute it.

    Same thing with example5. The error is saying that the end of your HEREDOC can not be found.

    Code:
        my $prefs = $ff->repl->expr(<<'JS');
          Components.classes["@mozilla.org/preferences-service;1"]
            .getService(Components.interfaces.nsIPrefBranch);
        JS
    JS is supposed to indicate the end of the HEREDOC. There can't be space in front of that terminator.

    There error of example6 may be more serious. There is still a complaint about a module failing to load. Does that script work for you on another machine?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    327
    Rep Power
    0
    hello dear Keath

    many many thanks for the quick reply. And for all the valuable hints.

    BTW: You deserve a monster congratulation. Your help is very very valuable.

    regarding the mentioned errors. I took two of the three code examples from the above mentioned site at CPAN: Code example three and five. I took all those examples by cutting and paste.

    Number six comes from another source. And yes: it does not work on another machine [yet]. Does it work for you!? That would be very very interesting.


    Again: the last posting with the mentioned examples reports the new situation that is reached with a fresh installation.

    As mentioned above it seems to me that

    WWW::Mechanize::FireFox (version 068) is in place

    But anyway - as you mention in your posting - i guess that there are still some errors left.

    i will have a closer look in the next few days.


    I come back and report all my findings...

    Again many many thanks for the great help so far.

    greetings

    metabo
  22. #12
  23. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    Originally Posted by metabo
    Does it work for you!? That would be very very interesting.
    I'm on a long trip, driving across the country. I won't be able to test that for a few more days unfortunately. If it can wait, I'll try later this week.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    327
    Rep Power
    0
    hello dear keath

    Originally Posted by keath
    I'm on a long trip, driving across the country. I won't be able to test that for a few more days unfortunately. If it can wait, I'll try later this week.
    many thank - i would appreciate it.

    have a good travel

    greetings
  26. #14
  27. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    OK, I've tested your script using Firefox version 16.0.2 on Mac OS X Mountain Lion.

    I've changed it just slightly, out of habit I suppose. I didn't see any big errors.

    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    
    use WWW::Mechanize::Firefox;
    
    my @urls = qw(
    	http://www.google.com
    	http://www.yahoo.com
    	http://www.cnn.com
    	http://www.bing.com
    	http://www.nbcnews.com
    );
    
    my $temp = '/tmp';
    my $mech = WWW::Mechanize::Firefox->new('create');
    
    foreach my $url (@urls){
    	my ($name) = $url =~ /www\.(\w+)\.com/;
    	print "creating $name.png\n";
    	 
    	$mech->get($url);
    	sleep(5);
    	my $png = $mech->content_as_png(undef, undef, {width => 240, height => 240});
    	
    	my $file = "$temp/$name".".png";
    	open my $fh, ">", $file or die "couldnt create $file";
    	binmode $fh;
    	print $fh $png;
    	close $fh;
    }
    
    print "done!\n";
    It works for me. This error that you mentioned earlier seems like a build error:

    Failed to connect to , Couldn't load "MozRepl::Plugin::Base", "Attempt to reload MozRepl/Plugin/Base.pm aborted.
    Compilation failed in require at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 82.
    " at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 84.
    So I'll just describe what I did to get things running.

    I already had Firefox installed. I didn't compile it myself, I just downloaded a binary.

    I got Mozrepl through the Firefox addons menu. Installed the latest version and restarted Firefox. It's then necessary to go to the Tools menu and turn in on manually. It won't come on automatically after restart.

    Then I left Firefox running, and downloaded the latest version of WWW::Mechanize::Firefox from CPAN. The instructions were on the INSTALL link. Rather than installing from the CPAN shell, I downloaded using the DOWNLOAD link, unzipping that file on my hard drive, and then opened a terminal and navigated into the unzipped directory. From there, I ran
    sudo cpan .
    and the installation began. I allowed any additional modules to be installed. Some tests were skipped because I didn't have some testing modules, but everything that ran passed.

    And that's it. I ran the script and it created thumbnails in my temp directory.

    I moved your sleep command up higher, after the get. It was necessary, because Firefox wasn't waiting for the full page to render before creating images, so the more complex pages like Yahoo and MSNBC were rendered as simpler preceding pages like Google before the delay was added.

    I didn't like that solution. I'm sure there is a better way of waiting for an event which shows the page load is complete, but that's all the time I can put into it today. I'm sure the sleep can be shortened though.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    327
    Rep Power
    0
    hi keath,

    many many thanks yor the help - all your help is appreciated.

    it is great to see that you got the script workin on your machine.


    i will digg into all the hints and try to solve the build-issues here.

    i come back the next days and report all the findings
    greetings
    meta

    btw: sometimes i muse bout a LIVE DVD or CD with all the necessary parts on it. Dont you think that this could be a way to go round the nasty issues with the installation of mozrepl and www:mechanize:firefox

    what do you say? guess that this modules were the most tricky ones i ever tried to install and get to run...!?


    by the way: the interesting thing is that we have a significant change:


    ....now on the new installation i have a different error report - compared with the dozenz of resluts saying another thing - see the error report number 2



    see error report number 1

    Code:
    Failed to connect to , Couldn't load "MozRepl::Plugin::Base", "Attempt to reload MozRepl/Plugin/Base.pm aborted.
    Compilation failed in require at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 82.
    " at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 84.

    some additional ideas regarding the failure of loading the
    see error report number 2


    Code:
    martin@linux-wyee:~/perl> perl moz_test1.pl 
    Can't locate WWW/Mechanize/Firefox.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.16.0 /usr/lib/perl5/vendor_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.16.0 /usr/lib/perl5/5.16.0/i586-linux-thread-multi /usr/lib/perl5/5.16.0 /usr/lib/perl5/site_perl/5.16.0/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.16.0 /usr/lib/perl5/site_perl .) at moz_test1.pl line 4. 
    BEGIN failed--compilation aborted at moz_test1.pl line 4. 
    martin@linux-wyee:~/perl> ^C 
    martin@linux- 
    wyee:~/perl>
    what do you say - i guess that there are really different things . that lead to the above mentioned reports... i will dig deeper into all the things and come back...

    and yes - i also try to build a remastered linux-live cd with all the necessary stuff..


    btw see the error report that i have Can't locate MozRepl.pm


    Code:
    Can't locate MozRepl.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1
    /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .)
    at /usr/local/share/perl/5.10.1/MozRepl/RemoteObject.pm line 402
    Well, i guess that this happens when MozRepl::RemoteObject cannot be loaded.

    hmm - some ideas: well guess that i have to install MozRepl for the system, not a single user only.





    btw see here - is this normal!? see the mozrepl-starting process:

    https://github.com/bard/mozrepl/wiki/Starting-the-REPL

    Code:
    martin@linux-wyee:~>    
    martin@linux-wyee:~>     telnet localhost 4242
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    
    Welcome to MozRepl.
    
     - If you get stuck at the "...>" prompt, enter a semicolon (;) at the beginning of the line to force evaluation.
     - If you get errors after every character you type, see http://github.com/bard/mozrepl/wikis/troubleshooting (short version: stop using Microsoft telnet, use netcat or putty instead)
    
    Current working context: chrome://browser/content/browser.xul
    Current input mode: syntax
    
    repl>


    keath - what do you say!?

    love to hear from you .....
    Last edited by metabo; November 24th, 2012 at 08:43 PM.

IMN logo majestic logo threadwatch logo seochat tools logo