On 11.11-22:32, ropers wrote: [ ... ] > So far, I have created a script .telnet4firefox.sh in my home folder, > made that executable (chmod u+x), and in Firefox' about:config I have > added a new boolean network.protocol-handler.external.telnet (set to > true) and a new string network.protocol-handler.app.telnet (set to > /home/ropers/.telnet4firefox.sh). The contents of the script are: > > #!/bin/sh > xterm -e "telnet ${1##telnet://}" > > When I click a telnet URL that does not specify a port, it works, > xterm launches with telnet, which duly connects to the port. [ ... ] > Currently, if I click on telnet://mud.vhdev.com:1991, telnet is called with > > telnet mud.vhdev.com:1991 > > instead of > > telnet mud.vhdev.com 1991
just do a little more work with '/bin/sh'. the other example posted is fine if all URLs are well formed, otherwise i'd suggest you do a little more work (i.e. don't trust IFS to work). #!/bin/sh ### execute telnet in xterm # grab the url ... URL=$1 # ... and strip the protocol from the front URL_noproto=${URL#telnet://} # remove any trailing bits from URL URL_addr=${URL_noproto%%/*} # strip URL_addr to the first ':' to get the host ... host_taint=${URL_addr%:*} # ... and strip unexpected stuff host=${host_taint%%[^A-Za-z.-]*} # strip URL_addr to the last ':' to get the port ... port_taint=${URL_addr##*:} #... and strip unexpected stuff port=${port_taint%%[^0-9]*} xterm -e "telnet ${host} ${port}" you could also do a little more sanity checking if you're paranoid (sensible?) but you won't gain much except overhead by using awk as the amount of sanity required checking for URLs and all the possible encodings is extensive. the best option is probably to invoke perl or python and use a standard URL library to parse the argument. -- t t w