1: #!/bin/ksh 2: 3: # If we have not redirected standard output, save a copy of 4: # the output of this script into a file, but still send a 5: # copy to the screen. 6: 7: if [[ -t 1 ]] ; then 8: # Only do this if fd 1 (stdout) is still connected 9: # to a terminal 10: 11: # We want the standard output of the "tee" process 12: # to go explicitly to the screen (/dev/tty) 13: # and the second copy goes into a logfile named $0.out 14: 15: tee $0.out >/dev/tty |& 16: 17: # Our stdout all goes into this coprocess 18: exec 1>&p 19: fi 20: 21: # Now generate some output 22: print "User activity snapshot on $(hostname) at $(date)" 23: print 24: who
last modified 22/03/2012 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |