home *** CD-ROM | disk | FTP | other *** search
- #!/bin/csh -f
- # 1 Dec 85 Tim Radzykewycz: as released
- # 2 Jan 86 Robert Adams: removed debugging, parameterized things, commented
- #
- set BANG = '\!'
- set PathFile = "/usr/spool/uumap/paths"
- #
- # Find host name and user name. This should be able to parse
- # addresses of the form uname@host and host!uname, and the
- # first form should have priority, so that the combined
- # form 'host1!uname@host0' can be used.
- # Notice that this doesn't know about domaining! In fact, it
- # strips any internet type domaining out before doing the host
- # search in the PathFile.
- #
- # Invocation is: getpath address
- # where getpath will output to standard out the path to the
- # user found in the PathFile. If no path is found, the
- # unmodified path is output. If no "address" is given, getpath
- # reads it from standard input.
- #
- echo $1 | sed 's/\..*//' > /tmp/$$
- if ("$1" == "") then
- echo $< | sed 's/\..*//' > /tmp/$$
- endif
- grep -s '@' /tmp/$$
- # if there were matches, use form 'uname@host'
- if ($status == 0) then
- set host = `sed -e "s/.*@//" /tmp/$$`
- set uname = `sed -e "s/${host}//" -e "s/@//" /tmp/$$`
- else
- set host = `sed -e "s/${BANG}.*//" /tmp/$$`
- set uname = `sed -e "s/${host}//" -e "s/${BANG}//" /tmp/$$`
- endif
- #
- # Now, find the path to that host, and tack on the uname
- # to the end of it.
- set e_path = `grep "^${host} " $PathFile`
- set uupath=`echo ${e_path} | sed -e 's/.*[ ]//' -e "s/%s/${uname}/" | sed -e "s/${BANG}${BANG}/${BANG}/g"`
- if ("$uupath" == "") then
- set uupath=`cat /tmp/$$`
- endif
- echo $uupath
- rm -f /tmp/$$
-