in reply to mozilla -remote made simple
A bit tidier and more reliable:
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.#!/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, $_);
Makeshifts last the longest.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: mozilla -remote made simple
by Anonymous Monk on Jan 15, 2004 at 17:00 UTC | |
by b10m (Vicar) on Jan 15, 2004 at 17:11 UTC |
In Section
Cool Uses for Perl