1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#!/bin/bash
#
# url_handler.sh for SuSE Linux
#
# Copyright (c) 2000 SuSE GmbH Nuernberg, Germany.
#
# Author: Werner Fink <werner@suse.de>
#
url="$1"
method="${1%%:*}"
if test "$url" = "$method" ; then
case "${url%%.*}" in
www|web|w3) method=http ;;
mail|mailx) method=mailto ;;
gopher) method=gopher ;;
*)
case "${url}" in
*/*.htm|*/*.html) method=http ;;
*/*.htmls) method=https ;;
*@*) method=mailto ;;
/*) if test -r "${url}" ; then
method=file
fi ;;
*) ;;
esac
;;
esac
case "$method" in
mailto|file) url="${method}:$url" ;;
*) url="${method}://$url" ;;
esac
fi
### an alternative method of handling "news:*" URL's
#
# if test "$method" = "news" ; then
# url="http://www.deja.com/[ST_rn=if]/topics_if.xp?search=topic&group=${url#news:}"
# method=http
# fi
shift
case "$method" in
ftp)
ftp=ftp
if type -p ncftp >& /dev/null ; then
ftp=ncftp
else
url="${url#ftp://}"
echo "=====> Paste this command by mouse:"
echo cd "/${url#*/}"
url="${url%%/*}"
fi
exec $ftp "$url"
;;
file|http|https|gopher)
http=
type -p lynx >& /dev/null && http=lynx
test -n "$DISPLAY" && type -p netscape >& /dev/null && http=netscape
test -n "$DISPLAY" && type -p Netscape >& /dev/null && http=Netscape
case "$http" in
[nN]etscape) $http -remote "openURL($url)" || $netscape "$url" ;;
lynx) exec $http "$url" ;;
*)
echo "No HTTP browser found."
read -p "Press return to continue: "
exit 0 # No error return
;;
esac
;;
mailto)
: ${MAILER:=mutt}
if type -p ${MAILER} >& /dev/null ; then
exec ${MAILER} "${url#mailto:}"
else
echo "No mailer ${MAILER} found in path."
echo "Please check your environment variable MAILER."
read -p "Press return to continue: "
exit 0 # No error return
fi
;;
*)
echo "URL type \"$method\" not know"
read -p "Press return to continue: "
exit 0 # No error return
;;
esac
|