1: #!/bin/ksh 2: # This example uses a locally written tool for Dartmouth Name Directory lookups 3: 4: # Start the dndlookup program as a coprocess 5: # Tell it to output only the canonical full name, and to not print multiple matches 6: dndlookup -fname -u |& 7: 8: # move the input/output streams so we 9: # can use other coprocesses too 10: exec 4>&p 11: exec 5<&p 12: 13: echo "Name file contents:" 14: cat namefile 15: echo 16: 17: # read the names from a file "namefile" 18: while read uname; do 19: print -u4 $uname 20: read -u5 dndname 21: case $dndname in 22: *many\ matches*) 23: # handle case where the name wasn't unique 24: print "Multiple matches to \"$uname\" in DND" 25: ;; 26: *no\ match*) 27: # handle case where the name wasn't found 28: print "No matches to \"$uname\" in DND" 29: ;; 30: *) 31: # we seem to have a hit - process the 32: # canonical named retrieved from dndlookup 33: print "Unique DND match: full name for \"$uname\" is \"$dndname\"" 34: ;; 35: esac 36: sleep 2 37: done < namefile 38: 39: # We've read all the names, but the coprocess 40: # is still running. Close the pipe to tell it 41: # we have finished. 42: exec 4>&-
last modified 22/03/2012 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |