#!/bin/sh # # $Id: yak,v 1.1 2003/02/04 01:14:21 jmates Exp $ # # The author disclaims all copyrights and releases this document into # the public domain. # # Unix diagnostic tool that saves various invocation details such as # arguments, environment settings, and standard input to a temporary # file for debugging. Uses include seeing how and with what settings # applications such as the LPRng print spooler or the Procmail mail # delivery agent call filters or external scripts. # # Output is saved to a temporary file under /tmp by default. shortname=`basename $0` shortname=${shortname:=yak} #OUTPUT=/dev/null OUTPUT=`mktemp -q /tmp/${shortname}.XXXXXX` if [ $? -ne 0 ]; then OUTPUT=/tmp/${shortname}.$$ fi #logger -t $shortname "saving output to $OUTPUT" ( if [ $# -gt 0 ]; then echo ARGS::BEGIN echo "$0 $@" echo ARGS::END else echo ARGS::NONE fi echo echo UNIX::BEGIN echo pid=$$ # may need to fiddle with this or use other utilities to get the real # vs. effective user and group settings id echo UNIX::END echo if test -t 0; then echo TTY::BEGIN tty echo TTY::END else echo TTY:NONE fi echo echo ENV::BEGIN set echo ENV::END echo # this will stall the script on command line waiting for input echo STDIN::BEGIN cat echo STDIN::END ) >> $OUTPUT exit 0