#!/bin/sh # # openurl 2010-05-23 # # (c) 2005..2010 by Dirk Jagdmann # # published under the zlib/libpng license: # http://www.opensource.org/licenses/zlib-license.php # no argument? if [ -z "$1" ] ; then exit 0 fi # check BROWSER variable if [ -z "$BROWSER" -o "$BROWSER" = openurl ] ; then export BROWSER=firefox fi # start up BROWSER if not running if [ -z `pidof firefox-bin` ] then $BROWSER > /dev/null 2>&1 & sleep 5 fi # now open all URLS from the command line for i in "$@" do # check for an URL if perl -e 'exit !($ARGV[0]=~/^((http)|(https)|(ftp)):\/\//i)' "$i" then $BROWSER "$i" # check for absolute path elif perl -e 'exit !($ARGV[0]=~/^\//)' "$i" ; then if [ -f "$i" ] ; then $BROWSER "file:$i" fi # it is a relative path else FN="$PWD/$i" if [ -f "$FN" ] ; then $BROWSER "file:$FN" else # we assume it is a hostname $BROWSER "http://$i" fi fi sleep 1 done