On Fri, 20 Aug 1999, Brian Salter-Duke wrote:
> On Thu, Aug 19, 1999 at 09:57:20AM -0400, Pete Toscano wrote:
> > in order to get it to play nicely with ncftp. it seems that, since i have
> > ncftp on my machine, url_view prefers to use (and i do too for that matter)
> > ncftp. well -- at least with the version of ncftp i have (3.0beta18 from
> > redhat 6.0 and 3.0beta19 from the redhat contrib archive) -- ncftp doesn't
> > handle gets with urls (ex. ftp.site.org:/pub/wherever/whatever.tgz), it just
> > suggests that you use ncftpget. because of this, i beat on url_handler.sh a
> > little bit and the attached patch is what fell out. this is a very simple
> > patch, but it seems to work for me whenever i use urlview to handle ftp urls.
> > all it does is look for a trailing '/' in the url and if there is one, it'll
> > fire up ncftp with the url, otherwise, it'll fire up ncftp get with the
> > url. i'm sure it's not handling all possible cases, but, like i said, it
> > works for me and i find it useful; i hope others will too.
> >
> > pete
>
> The problem with this fix is that not all URL's that you expect to
> have a trailing / may actually have one.
>
> I wrote a small modification to urlview that prints out a message about
> this before the menu. You can then edit the URL after selecting it
> to add the / id required. My url_handler.sh does much the same as Pete's
> except actually checking for ncftp. It amy handle some other things
> however. Take a look at:-
>
> http://lacebark.ntu.edu.au/mutt.html
>
> for my solution. Perhaps we need to merge together the various suggestions
> and have a better version of url_handler for the mutt-1.0 distribution.
i looked through your pages and i think your way of catching and checking
for the '/' is better, so i took your url_handler.sh, added in the ncftp/
ncftpget checking, added lynx as a possible http/web viewer for those running
x, but who don't have netscape loaded, and i removed your "local-isms",
such as using realmutt instead of mutt. i also made it check /usr/local/bin
in addition to /usr/bin for ncftp, ncftpget, and mutt.
problems i still see:
. do we want to make the directory vs file detection smarter? searching
for a '/' at the end seems kind of brain-dead, but can we make it better
without being a real pita? maybe have it search for the main gtlds, such
as ".com", ".org", ".edu", ".net", ".gov", and ".mil"? of course, this
ignores all the two-letter country codes and leads towards a possible
maintenance nightmare...
. my ftp client is very stupid; it only understands hostnames on the
command line, so i have ftp called only with the hostname is it can't
find ncftp or ncftpget. is this a safe assumption for other "ftp" clients?
. with my netscape (4.61 for linux),
"netscape -remote 'openURL(http://www.mutt.org)'"does not work. netscape is
started up and that's it. i know there's a way to get this working, but i
haven't been able to find an answer. it'd like to get this working.
please let me know if this works for you. do you know who we should submit
patches for urlview to?
ciao,
pete
--
Pete Toscano h:[EMAIL PROTECTED] w:[EMAIL PROTECTED]
GPG fingerprint: AE5C 18E4 D069 76D3 9B9C D226 D86A 522F 446C 767A
--- url_handler.sh.orig Fri Aug 20 10:07:10 1999
+++ url_handler.sh Fri Aug 20 13:44:10 1999
@@ -6,6 +6,10 @@
# Created by: Michael Elkins <[EMAIL PROTECTED]> on March 10, 1997
# Modified by: Liviu Daia <[EMAIL PROTECTED]>
# Last Edited: May 26, 1997
+# Modified by: Brian Salter-Duke <[EMAIL PROTECTED]>
+# Last edited: 19 June, 1999
+# Modified by: Pete Toscano <[EMAIL PROTECTED]>
+# Last edited: 20 Aug, 1999
#
url=$1
@@ -13,11 +17,19 @@
case $method in
ftp)
- target=`echo $url | sed 's;^.*://\([^/]*\)/*\(.*\);\1:/\2;'`
- if [ -x /usr/bin/ncftp ]; then
- ncftp $target
+ temp=`echo $url | sed 's/.$//;'`
+ if [ $temp/ = $url ]; then
+ if [ -x /usr/bin/ncftp -o -x /usr/local/bin/ncftp ]; then
+ ncftp $url
+ else
+ ftp `echo $url | sed 's;^.*://\([^/]*\)/*.*;\1;'`
+ fi
else
- ftp $target
+ if [ -x /usr/bin/ncftpget -o -x /usr/local/bin/ncftpget ]; then
+ ncftpget $url
+ else
+ ftp `echo $url | sed 's;^.*://\([^/]*\)/*.*;\1;'`
+ fi
fi
;;
@@ -25,12 +37,12 @@
if test x$DISPLAY = x; then
lynx $url
else
- netscape -remote "openURL($url)" || netscape $url
+ netscape -remote "openURL($url)" || netscape $url || lynx $url
fi
;;
mailto)
- if [ -x /usr/bin/mutt ]; then
+ if [ -x /usr/bin/mutt -o -x /usr/local/bin/mutt ]; then
mutt `echo $url | sed 's;^[^:]*:\(.*\);\1;'`
else
mail `echo $url | sed 's;^[^:]*:\(.*\);\1;'`
@@ -41,11 +53,19 @@
method=`echo $url | sed 's;\(^...\).*;\1;'`
case $method in
ftp)
- target=`echo $url | sed 's;^\([^/]*\)/*\(.*\);\1:/\2;'`
- if [ -x /usr/bin/ncftp ]; then
- ncftp $target
+ temp=`echo $url | sed 's/.$//;'`
+ if [ $temp/ = $url ]; then
+ if [ -x /usr/bin/ncftp -o -x /usr/local/bin/ncftp ]; then
+ ncftp "ftp://"$url
+ else
+ ftp `echo "ftp://"$url | sed
+'s;^.*://\([^/]*\)/*.*;\1;'`
+ fi
else
- ftp $target
+ if [ -x /usr/bin/ncftpget -o -x /usr/local/bin/ncftpget ]; then
+ ncftpget "ftp://"$url
+ else
+ ftp `echo "ftp://"$url | sed
+'s;^.*://\([^/]*\)/*.*;\1;'`
+ fi
fi
;;
@@ -54,7 +74,7 @@
if test x$DISPLAY = x; then
lynx $target
else
- netscape -remote "openURL($target)" || netscape $target
+ netscape -remote "openURL($target)" || netscape $target || lynx
+$target
fi
;;
PGP signature