#!/usr/bin/perl -w # # openInSafari # # 2008-10-02: Written by Steven J. DeRose. # # To do: use strict; use Getopt::Long; my $version = "2010-09-12"; my $quiet = 0; my $verbose = 0; ############################################################################### # Getopt::Long::Configure ("ignore_case"); my $result = GetOptions( "h|help" => sub { system "perldoc openInSafari"; exit; }, "q!" => \$quiet, "v+" => \$verbose, "version" => sub { die "Version of $version, by Steven J. DeRose.\n"; } ); ($result) || die "Bad options.\n"; ############################################################################### # my $uri = "file://$ENV{PWD}/$ARGV[0]"; my $s = "tell Application \"Safari\" activate set the URL of window 1 to \"$uri\" end tell "; my $tfile = "/tmp/openInSafari\n"; open OUT, ">$tfile" || die "Couldn't open temp file at '$tfile'.\n"; print OUT $s; close OUT; system "osascript $tfile" || warn "osascript failed.\n"; exit; ############################################################################### sub showUsage { warn " =head1 Usage openInSafari [options] [uri] Runs an AppleScript to open the given URI in Safari. =head1 Options =over =item * B<-q> Suppress most messages. =item * B<-v> Add more messages, and check integrity frequently. =item * B<-version> Show version/license info and exit. =back =head1 Known bugs and limitations =head1 Related commands =head1 Ownership This work by Steven J. DeRose is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. For further information on this license, see http://creativecommons.org/licenses/by-sa/3.0/. The author's present email is sderose at acm.org. For the most recent version, see http://www.derose.net/steve/utilities/. =cut "; }