1 #! /bin/sh 2 # 3 # example of how to call the appropriate viewer 4 # based on a script by Michael Elkins <me@cs.hmc.edu> 5 # 2001-01-31 <urs@tin.org> 6 # 7 # URLs must start with a scheme and shell metas must be already quoted 8 # (tin doesn't recognize URLs without a scheme and it quotes the metas) 9 # 10 # TODO: check $BROWSER? 11 12 if test $# -ne 1; then 13 echo "Usage: `basename $0` URL" >&2 14 exit 1 15 fi 16 17 url=$1 18 method=`echo $url | sed 's,^\([^:]*\):.*,\1,' | tr 'A-Z' 'a-z'` 19 20 case $method in 21 http|https|gopher) 22 if test x$DISPLAY = x; then 23 lynx $url || exit 1 24 else 25 ( netscape -remote openURL\($url\) || netscape $url ) || exit 1 26 fi 27 ;; 28 29 ftp) 30 if test x$DISPLAY = x; then 31 target=`echo $url | sed 's;^.*://\([^/]*\)/*\(.*\);\1:/\2;'` 32 ( ncftp $target || ncftp $target"/" ) || exit 1 33 else 34 ( netscape -remote openURL\($url\) || netscape $url ) || exit 1 35 fi 36 ;; 37 38 mailto) 39 ( mutt `echo $url` ) || exit 1 40 # ( pine -url `echo $url` ) || exit 1 41 # # old mutts can't handle mailto:-URLs with embedet subject 42 # if test `echo $url | grep -c '\?'` -eq 0 ; then 43 # ( mutt `echo $url | sed 's;^[^:]*:\(.*\);\1;'` ) || exit 1 44 # else 45 # if test x$DISPLAY = x; then 46 # lynx $url || exit 1 47 # else 48 # ( netscape -remote openURL\($url\) || netscape $url ) || exit 1 49 # fi 50 # fi 51 ;; 52 53 news|snews) 54 # usually meant for reading news on the local server 55 if test x$DISPLAY = x; then 56 lynx $url || exit 1 57 else 58 ( netscape -remote openURL\($url\) || netscape $url ) || exit 1 59 fi 60 ;; 61 62 nntp) 63 # usually meant for reading news via NNTP 64 # needs a special case as netscape can't handle nntp-URLs 65 # *sigh* 66 lynx $url || exit 1 67 ;; 68 69 esac 70 71 exit 0