Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

mozilla -remote made simple

by giulienk (Curate)
on Oct 10, 2002 at 10:43 UTC ( [id://204134]=CUFP: print w/replies, xml ) Need Help??

I find really interesting the capability of mozilla to open new URLs in new tabs of a already running mozilla process. Still i find the syntax of the command awkward and not really usable. So I added the following snippet to my PATH. It's really simple, but makes the trick.

NB: tested with Mozilla 1.1. It should work even with Mozilla 1.0 but i'm pretty sure it won't work for previous versions.

#!/usr/bin/perl use strict; use constant USAGE => <<EOU; USAGE: $0 (filename|URL|mailto:email\@addre.ss) EOU $_ = shift; my $command = 'openURL(%s, new-tab)'; SWITCH: { s!^(www\..+)!http://$1!; m!^(ftp|http|file)://! and last; s!^mailto:!! and do { $command = 'mailto(%s)'; last; }; -r and do { require Cwd; $_ = 'file://' . Cwd::abs_path( $_ ); last; }; print USAGE and exit; } system "mozilla", "-remote", sprintf($command, $_);

Replies are listed 'Best First'.
Re: mozilla -remote made simple
by Helter (Chaplain) on Oct 10, 2002 at 13:00 UTC
    I've been waiting for this feature.....here at work we have Mozilla 1.0 i686 Linux, and new-tab is not understood. I'm downloading a local copy of 1.2....hopefully it will make all my dreams come true :)
Re: mozilla -remote made simple
by mirod (Canon) on Oct 10, 2002 at 13:51 UTC

    Sweet!

    It works with phoenix too (provided you replace mozilla by phoenix of course!)

Re: mozilla -remote made simple
by Aristotle (Chancellor) on Dec 24, 2002 at 16:38 UTC
    A bit tidier and more reliable:
    #!/usr/bin/perl -w use strict; use constant URL => 'openURL(%s, new-tab)'; use constant MAIL => 'mailto(%s)'; sub abs_path { require File::Spec; File::Spec->rel2abs(shift); } $_ = shift || ''; my $command = m!^(?:ftp|http|file)://! ? sprintf URL, $_ : -r($_) ? sprintf URL, 'file://'.abs_path($_) : s!^(www\..+)!http://$1! ? sprintf URL, $_ : s!^(ftp\..+)!ftp://$1! ? sprintf URL, $_ : s/^mailto:// ? sprintf MAIL, $_ : die "usage: $0 (filename|URL|mailto:foo\@bar.com)\n"; exec 'mozilla', -remote => sprintf($command, $_);
    This checks -r early - thus, you can use it to invoke Mozilla on a directory called www.foo.bar/ without the scheme guessing getting in your way. It also handles URLs with ftp.* hosts nicely.

    Makeshifts last the longest.

      Do you know how to start Mozilla mail with the message text already filled in?

        Dunno if this works with all/more browsers, but it does seem to work with Firebird (and I hope this is what you're looking for):

        <a href="mailto:foo@bar.invalid?subject=Testing&body=Oh wow, body text +">foo@bar.invalid</a>

        This works for me, using Firebird and MozEX to launch Pine for me.

        Test it here :) foo@bar.invalid

        --
        b10m
Re: mozilla -remote made simple
by Aristotle (Chancellor) on Oct 10, 2002 at 18:34 UTC
    Very minor personal pet peeve :-) : print(USAGE), exit; You don't actually want to depend on print's return value there - using and works but is more of an accidental feature. ++ though!

    Makeshifts last the longest.

Re: mozilla -remote made simple
by Mr. Muskrat (Canon) on Oct 10, 2002 at 14:02 UTC

    This does not yet work with Phoenix.

    Update: At least not on win98.

Re: mozilla -remote made simple
by Mr. Muskrat (Canon) on Oct 30, 2002 at 16:48 UTC

    I upgraded to Phoenix 0.4 this morning and now this works even on Windows 98.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-18 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found